<style>
    :root {
        --color1: #009C5E;
        --bgColor1: #009C5E;
        --color2: #fff;
        --bgColor2: #fff;
        --mainBtnColor1: #009C5E;
        --mainBtnBgColor1: #FFF;
        --mainBtnColor2: #FFF;
        --mainBtnBgColor2: #009C5E;
        --mainBtnColor3: #000;
    }
    xm-select{
        box-sizing: border-box;
    }
    .noData {
        font-size: 20px;
        text-align: center;
        line-height: 100px;
    }

    .layui-card {
        background-color: transparent;
        overflow: hidden;
    }

    .layui-fluid .layui-card .layui-card-body {
        padding: 0;
    }

    .whole {
        width: 100%;
        height: 100%;
        display: flex;
    }

    /*主柜*/
    .main {
        width: 640px;
        height: 100%;
        overflow: hidden;
    }


    /*主柜头部*/
    .mainHeader {
        padding: 12px 20px;
        height: 66px;
        background: rgba(0, 156, 94, 0.06);
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mainHeaderTitle {
        font-size: 20px;
        font-weight: bold;
        color: #333333;
    }

    .mainHeaderTitleNum {
        color: #009C5E;
    }

    /*主柜内容列表*/
    .mainBox {
        height: calc(100% - 60px);
        overflow-y: auto;
    }

    .mainBox::-webkit-scrollbar-thumb {
        background-color: transparent;
    }

    .mainBox::-webkit-scrollbar {
        width: 5px;
    }

    .mainBox:hover::-webkit-scrollbar-thumb {
        background-color: #ccc;
    }

    .mainBoxList {
        height: auto;
    }

    .mainBoxItem {
        padding: 20px;
        box-sizing: border-box;
        width: 100%;
        height: 202px;
        cursor: pointer;
        border-radius: 10px 0 0 10px;
    }

    .mainBoxItem.active {
        background-color: #fff;
    }

    .mainBoxContent {
        box-sizing: border-box;
        border-radius: 5px 5px 5px 5px;
        border: 1px solid transparent;
        height: 162px;
        width: 100%;
        background-image: url('assets/images/cabinet/mainBg.png');
        background-size: 100% 100%;
        background-repeat: no-repeat;
        padding: 14px;
        display: flex;
        overflow: hidden;
        transition: all 1300ms;
    }

    .mainBoxItem.active > .mainBoxContent {
        border: 1px solid #ECECEC;
        background-color: var(--mainBtnBgColor1);
        background-image: none;
    }

    .mainBoxContentImg {
        width: 134px;
        height: 134px;
        background: #FFFFFF;
        border-radius: 6px 6px 6px 6px;
        margin-right: 14px;
    }

    .mainBoxItem.active .mainBoxContentImg {
        background: #F4F4F4;
    }

    .mainBoxContentImg > img {
        max-width: 100%;
        max-height: 100%;
    }

    .mainBoxContentRight {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .mainBoxContentName {
        font-size: 18px;
        font-weight: bold;
        color: var(--mainBtnBgColor1);
    }

    .mainBoxItem.active .mainBoxContentName {
        color: var(--mainBtnColor3);
    }

    .mainBoxContentInfo {
        display: flex;
    }

    .mainBoxContentInfo > div {
        flex: 2;
        font-size: 14px;
        color: #BBE1D2;
        padding-right: 10px;
    }

    .mainBoxContentInfo > div:first-child {
        flex: 3;
    }

    .mainBoxItem.active .mainBoxContentInfo > div {
        color: var(--mainBtnColor3);
    }

    .mainBoxContentBtn {
        display: flex;
        justify-content: space-between;
    }

    .mainBoxContentButton {
        box-sizing: border-box;
        padding: 5px 13px;
        background: var(--mainBtnBgColor1);
        border-radius: 40px 40px 40px 40px;
        border: 1px solid var(--mainBtnBgColor1);
        font-size: 12px;
        color: var(--mainBtnColor1);
        line-height: 14px;
        cursor: pointer;
    }

    .mainBoxItem.active .mainBoxContentButton {
        background: var(--mainBtnBgColor2);
        color: var(--mainBtnColor2);
    }

    .mainBoxContentButton.details {
        color: var(--mainBtnColor2);
        background: var(--mainBtnBgColor2);
        border: 1px solid var(--mainBtnBgColor1);
    }

    .mainBoxItem.active .mainBoxContentButton.details {
        color: var(--mainBtnColor1);
        background: var(--mainBtnBgColor1);
        border: 1px solid var(--mainBtnBgColor2);
    }

    /*副柜*/
    .auxiliary {
        flex: 3;
        height: 100%;
        overflow: hidden;
        background-color: #fff;
        padding: 12px 20px 20px;
        box-sizing: border-box;
    }

    .auxiliaryHeader {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
    }

    .auxiliaryHeaderTitle {
        font-size: 20px;
        font-weight: bold;
        color: #333333;
    }

    .auxiliaryHeaderTitleNum {
        color: #009C5E;
    }

    .auxiliaryHeaderAdd > .layui-btn:not(.layui-btn-primary):not(.layui-btn-normal):not(.layui-btn-warm):not(.layui-btn-danger):not(.layui-btn-disabled) {
        background-color: var(--bgColor2);
        color: var(--color1);
        border: 1px solid var(--bgColor1);
    }


    .auxiliaryBox {
        height: calc(100% - 60px);
        overflow-y: scroll;
    }

    .auxiliaryBox::-webkit-scrollbar-thumb {
        background-color: transparent;
    }

    .auxiliaryBox::-webkit-scrollbar {
        width: 5px;
    }

    .auxiliaryBox:hover::-webkit-scrollbar-thumb {
        background-color: #ccc;
    }

    .auxiliaryBoxItem {
        padding: 14px;
        box-sizing: border-box;
        display: flex;
        border-radius: 5px 5px 5px 5px;
        border: 1px solid #ECECEC;
        margin-bottom: 20px;
    }

    .auxiliaryBoxItemImg {
        width: 134px;
        height: 134px;
        background: #F4F4F4;
        border-radius: 6px 6px 6px 6px;
        overflow: hidden;
        margin-right: 14px;
    }

    .auxiliaryBoxItemImg > image {
        width: 100%;
        height: 100%;
    }

    .auxiliaryBoxItemInfo {
        /*width: 350px;*/
        box-sizing: border-box;
        margin-right: 14px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        flex: 1;
    }

    .auxiliaryBoxItemInfoTitle {
        font-size: 18px;
        font-weight: bold;
        color: #333333;
    }

    .auxiliaryBoxItemInfo1 {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
    }

    .auxiliaryBoxItemInfo1 > span {
        color: #333333;
    }

    .auxiliaryBoxItemBtn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    form.layui-form.model-form.mainCabinetDetailsForm,
    form.layui-form.model-form.mainCabinetAuthorityForm {
        padding: 20px 30px 0 30px;
        height: calc(100% - 25px);
        overflow: hidden;
    }

    .mainCabinetDetailsForm .open-details-box {
        height: calc(100% - 65px);
        overflow: scroll;
    }

    .mainCabinetAuthorityForm .open-details-box {
        height: calc(100% - 100px);
        overflow: auto;
    }

    .mainCabinetStagingForm .open-details-box,
    .mainCabinetOrderForm .open-details-box,
    .mainCabinetOrderDetailsForm .open-details-box,
    .mainCabinetCargoForm .open-details-box,
    .mainCabinetProductForm .open-details-box,
    .mainCabinetModifyForm .open-details-box,
    .transferForm .open-details-box {
        height: calc(100% - 50px);
        overflow: auto;
    }

    .mainCabinetDetailsForm label,
    .mainCabinetOrderDetailsForm label,
    .cargoLanelModifyForm label,
    .alarmSettingForm label,
    .mainCabinetModifyForm label,
    .transferForm label {
        width: 120px;
    }

    .alarmSettingForm .layui-input-block {
        margin-left: 150px;
    }

    form[lay-filter="addPermissionGroupMembersForm"] label {
        padding: 9px;
        width: 90px;
    }

    form[lay-filter="addPermissionsGroupForm"] label {
        padding: 9px;
        width: 100px;
    }

    form[lay-filter="addPermissionsGroupForm"] input {
        width: 280px;
    }

    form[lay-filter="addPermissionsGroupForm"] .open-details-box .layui-row .layui-inline {
        height: 58px;
        transition: all 300ms;
    }

    form[lay-filter="addPermissionsGroupForm"] .layui-radio-disbaled>i{
        color: #1BA70E !important;
    }


    .mainCabinetAuthorityForm label,
    .mainCabinetStagingForm label,
    .mainCabinetCargoForm label,
    .mainCabinetOrderForm label {
        width: auto;
        padding: 9px 0;
    }

    .mainCabinetProductForm label {
        width: auto;
        padding: 9px;
    }

    .layui-form.model-form.mainCabinetCargoForm,
    .layui-form.model-form.mainCabinetStagingForm,
    .layui-form.model-form.mainCabinetStagingDetailedForm,
    .layui-form.model-form.mainCabinetProductForm,
    .layui-form.model-form.mainCabinetOrderForm,
    .layui-form.model-form.mainCabinetOrderDetailsForm,
    .layui-form.model-form.mainCabinetModifyForm,
    .layui-form.model-form.transferForm {
        padding: 20px 20px 0 20px;
        height: calc(100% - 25px);
        overflow: hidden;
    }

    .mainCabinetDetailsForm input,
    .mainCabinetOrderDetailsForm input {
        border: none;
        outline: none;
    }

    /*主柜货道*/
    .cargoBox {
        height: 440px;
    }

    .cargoBoxItem {
        width: 400px;
        height: 204px;
        background: #FFFFFF;
        border-radius: 5px 5px 5px 5px;
        border: 1px solid #ECECEC;
        float: left;
        box-sizing: border-box;
        margin-right: 15px;
        margin-bottom: 15px;
        transition: all 1000ms;
        cursor: pointer;
    }

    .cargoBoxItem:hover {
        box-shadow: 1px 1px 5px rgba(0, 0, 0, .2);
    }

    .cargoBoxItem:nth-child(3n) {
        margin-right: 0;
    }

    .cargoBoxItemContent {
        box-sizing: border-box;
        padding: 9px 10px;
        display: flex;
        height: 162px;
        width: 100%;
    }

    .cargoBoxItemImage {
        width: 144px;
        height: 144px;
        margin-right: 20px;
        border-radius: 5px;
        overflow: hidden;
        position: relative;
    }

    .cargoBoxItemImage > img {
        width: 100%;
        height: 100%;
    }

    .cargoBoxItemImageTitle {
        position: absolute;
        left: 0;
        top: 0;
        width: 144px;
        height: 40px;
        background: #1399FD;
        color: #FFFFFF;
        font-weight: bold;
        text-align: center;
        line-height: 40px;
    }

    .cargoBoxItemInfo {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        overflow: hidden;
    }

    .cargoBoxItemInfoTitle {
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        overflow: hidden;
        white-space: nowrap;
    }

    .noImg {
        background: #999999;
    }

    .noBorder, .noBorder:focus, .noBorder:hover {
        border-color: transparent !important;
        outline-color: transparent !important;
    }

    .cargoBoxItemInfo1 {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        line-height: 16px;
        white-space: nowrap;
    }

    .cargoBoxItemInfoEdit {
        width: 100%;
        height: 40px;
        background: #FAFBFF;
        border-radius: 0 0 5px 5px;
        border-top: 1px solid #EDEDED;
        box-sizing: border-box;
        text-align: center;
        line-height: 40px;
        font-size: 12px;
        font-weight: 400;
        color: #333333;
        cursor: pointer;
    }


    .cargoBoxItemInfoEdit i {
        color: var(--color1);
    }

    .stagingBox {
        height: 570px;
    }

    .stagingBoxItem {
        display: flex;
        width: 230px;
        height: 280px;
        background: #FFFFFF;
        border-radius: 5px 5px 5px 5px;
        border: 1px solid #ECECEC;
        box-sizing: border-box;
        float: left;
        overflow: hidden;
        flex-direction: column;
        justify-content: space-between;
        cursor: pointer;
        transition: all 1000ms;
        margin-right: 20px;
        margin-bottom: 15px;
    }

    .stagingBoxItem:hover {
        box-shadow: 1px 1px 5px rgba(0, 0, 0, .2);
    }

    .stagingBoxItem:nth-child(5n) {
        margin-right: 0;
    }

    .stagingBoxItemHeader {
        width: 100%;
        text-align: center;
        line-height: 40px;
        height: 40px;
        overflow: hidden;
        background: #999999;
        color: #fff;
    }

    .stagingBoxItemHeaderBg1 {
        background-color: #1399FD;
    }

    .stagingBoxItemHeaderBg2 {
        background-color: #009C5E;
    }

    .stagingBoxItemHeaderBg3 {
        background-color: #FF9C04;
    }

    .stagingBoxItemHeaderBg4 {
        background-color: #647EFB;
    }

    .stagingBoxItemMain {
        flex: 1;
        padding: 20px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .stagingBoxItemTitle {
        height: 21px;
        font-size: 16px;
        font-weight: bold;
        color: #333333;
        line-height: 19px;
        margin-bottom: 15px;
        white-space: nowrap;
    }

    .stagingBoxItemInfo {
        height: 18px;
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        white-space: nowrap;
    }

    .stagingBoxItemInfo > span {
        color: #333333;
    }

    .stagingBoxItemFooter {
        line-height: 40px;
        background: #FAFBFF;
        border-top: 1px solid #EDEDED;
        display: flex;
    }

    .stagingBoxItemFooter > div {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }

    .stagingBoxItemFooter > div > i {
        color: #009C5E;
        margin-right: 3px;
        font-size: 20px;
    }

    /* 主柜订单*/
    .mainCabinetOrderItem {
        width: 100%;
        height: 140px;
        background: #FFFFFF;
        border-radius: 5px 5px 5px 5px;
        opacity: 1;
        border: 1px solid #ECECEC;
        box-sizing: border-box;
        margin-bottom: 10px;
        overflow: hidden;
    }

    .mainCabinetOrderItemHeader {
        display: flex;
        justify-content: space-between;
        height: 40px;
        background: rgba(0, 156, 94, 0.06);
        align-items: center;
    }

    .mainCabinetOrderItemCode {
        margin-left: 20px;
        font-size: 12px;
        font-weight: bold;
        color: #333333;
    }

    .mainCabinetOrderItemNum {
        padding: 4px 10px;
        background: #009C5E;
        border-radius: 12px 0 0 12px;
        font-weight: 400;
        color: #FFFFFF;
        line-height: 14px;
    }

    .mainCabinetOrderItemCenter {
        display: flex;
    }

    .mainCabinetOrderItemCenter > div {
        flex: 1;
        height: 100px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
    }

    .mainCabinetOrderItemCenter > div:not(:last-child) {
        border-right: 1px solid #ECECEC;
    }

    .mainCabinetOrderItemImg > div {
        width: 60px;
        height: 60px;
        background: #D9D9D9;
        border-radius: 5px 5px 5px 5px;
        overflow: hidden;
    }

    .mainCabinetOrderItemImg > div > * {
        max-height: 100%;
        height: 100%;
    }

    .mainCabinetOrderItemInfo > p:first-child {
        font-size: 14px;
        font-weight: 400;
        color: #333333;
        white-space: nowrap;
    }

    .mainCabinetOrderItemInfo > p:last-child {
        font-size: 14px;
        font-weight: 400;
        color: #999999;
        white-space: nowrap;
    }

    .mainCabinetOrderItemBtn .layui-btn {
        border-color: #009C5E;
        color: #009C5E;
    }

    .imgBox {
        width: 80px;
        height: 80px;
        background: #D9D9D9;
        margin-top: 10px;
        border-radius: 5px 5px 5px 5px;
        overflow: hidden;
    }
    .mainCabinetOrderDetailsForm .layui-form-item .layui-input-inline{
        width: 280px;
    }
    .colorBlack{
        padding-right: 15px;
        color: var(--color1);
        font-weight: 600;
    }
    .colorBlack1{
        padding-right: 15px;
    }
    .addPermissionGroupMembersDetail{
        display: none;
    }
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="whole">
                <!-- 主柜-->
                <div class="main">
                    <div class="mainHeader">
                        <div class="mainHeaderTitle">
                            主柜列表<span class="mainHeaderTitleNum" id="mainHeaderTitleNum">(0)</span>
                        </div>
                        <!--<div class="mainHeaderAdd">
                            <a class="layui-btn">
                                <i class="layui-icon layui-icon-addition"></i>
                                添加主柜
                            </a>
                        </div>-->
                    </div>
                    <div class="mainBox">
                        <div class="mainBoxList" id="mainBoxList">
                            <!--<div class="mainBoxItem">
                                <div class="mainBoxContent">
                                    <div class="mainBoxContentImg"></div>
                                    <div class="mainBoxContentRight">
                                        <div class="mainBoxContentName">主柜名称</div>
                                        <div class="mainBoxContentInfo">
                                            <div>主柜编号：<span>12345678</span></div>
                                            <div>副柜数量：<span>12345678</span></div>
                                        </div>
                                        <div class="mainBoxContentInfo">
                                            <div>货道数量：<span>12345678</span></div>
                                            <div>物料数量：<span>12345678</span></div>
                                        </div>
                                        <div class="mainBoxContentBtn">
                                            <div class="mainBoxContentButton details">详情</div>
                                            <div class="mainBoxContentButton power">权限</div>
                                            <div class="mainBoxContentButton cargo">货道</div>
                                            <div class="mainBoxContentButton staging">暂存柜</div>
                                            <div class="mainBoxContentButton product">物料</div>
                                            <div class="mainBoxContentButton order">订单</div>
                                            <div class="mainBoxContentButton modify">修改</div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="mainBoxItem active">
                                <div class="mainBoxContent">
                                    <div class="mainBoxContentImg"></div>
                                    <div class="mainBoxContentRight">
                                        <div class="mainBoxContentName">主柜名称</div>
                                        <div class="mainBoxContentInfo">
                                            <div>主柜编号：<span>12345678</span></div>
                                            <div>副柜数量：<span>12345678</span></div>
                                        </div>
                                        <div class="mainBoxContentInfo">
                                            <div>货道数量：<span>12345678</span></div>
                                            <div>物料数量：<span>12345678</span></div>
                                        </div>
                                        <div class="mainBoxContentBtn">
                                            <div class="mainBoxContentButton details">详情</div>
                                            <div class="mainBoxContentButton power">权限</div>
                                            <div class="mainBoxContentButton cargo">货道</div>
                                            <div class="mainBoxContentButton staging">暂存柜</div>
                                            <div class="mainBoxContentButton product">物料</div>
                                            <div class="mainBoxContentButton order">订单</div>
                                            <div class="mainBoxContentButton modify">修改</div>
                                        </div>
                                    </div>
                                </div>
                            </div>-->
                        </div>
                    </div>
                </div>

                <!--副柜-->
                <div class="auxiliary">
                    <div class="auxiliaryHeader">
                        <div class="auxiliaryHeaderTitle">
                            副柜列表
                            <span class="auxiliaryHeaderTitleNum" id="auxiliaryHeaderTitleNum">(0)</span></div>
                        <div class="auxiliaryHeaderAdd">
                            <!--                            <a class="layui-btn"><i class="layui-icon layui-icon-addition"></i>添加副柜</a>-->
                        </div>
                    </div>
                    <div class="auxiliaryBox">
                        <div class="auxiliaryBoxList" id="auxiliaryBoxList">
                            <h3 class="noData">暂无内容~~~</h3>
                            <!-- <div class="auxiliaryBoxItem">
                                 <div class="auxiliaryBoxItemImg"></div>
                                 <div class="auxiliaryBoxItemInfo">
                                     <div class="auxiliaryBoxItemInfoTitle">副柜名称</div>
                                     <div class="auxiliaryBoxItemInfo1">副柜编号：<span>12545632147552</span></div>
                                     <div class="auxiliaryBoxItemInfo1">货道数量：<span>20个</span></div>
                                     <div class="auxiliaryBoxItemInfo1">物料数量：<span>20个</span></div>
                                 </div>
                                 <div class="auxiliaryBoxItemBtn">
                                     <a class="layui-btn layui-btn-primary layui-btn-xs">详情</a>
                                     <a class="layui-btn layui-btn-xs">权限</a>
                                     <a class="layui-btn layui-btn-xs">货道</a>
                                     <a class="layui-btn layui-btn-xs">物料</a>
                                     <a class="layui-btn layui-btn-xs">订单</a>
                                     <a class="layui-btn layui-btn-xs">修改</a>
                                     <a class="layui-btn layui-btn-xs layui-btn-danger">转移</a>
                                 </div>
                             </div>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--主柜详情-->
<script type="text/html" id="mainCabinetDetailsForm">
    <form lay-filter="mainCabinetDetailsForm" class="layui-form model-form mainCabinetDetailsForm">
        <div class="open-details-box">
            <div class="layui-form-item layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">所属服务商</label>
                    <div class="layui-input-inline">
                        <input name="settledCompanyName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">柜子类型</label>
                    <div class="layui-input-inline">
                        <input name="typeName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">柜子型号</label>
                    <div class="layui-input-inline">
                        <input name="cabinetTypeDesc" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">所属品牌</label>
                    <div class="layui-input-inline">
                        <input name="brandName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">柜子名称</label>
                    <div class="layui-input-inline">
                        <input name="name" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">柜子编号</label>
                    <div class="layui-input-inline">
                        <input name="cabCode" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row spaceNumBox">
                <div class="layui-col-md6">
                    <label class="layui-form-label">存刀柜货位总数</label>
                    <div class="layui-input-inline">
                        <input name="cargoSpaceNumber" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">存刀单柜货位数</label>
                    <div class="layui-input-inline">
                        <input name="spaceNum" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row laneNumBox">
                <div class="layui-col-md6">
                    <label class="layui-form-label">售刀货道总数</label>
                    <div class="layui-input-inline">
                        <input name="cargoLaneNumber" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">售刀单柜货道数</label>
                    <div class="layui-input-inline">
                        <input name="laneNum" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">主板类型</label>
                    <div class="layui-input-inline">
                        <input name="motherboardName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">升降主板类型</label>
                    <div class="layui-input-inline">
                        <input name="hostTypeName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label">所属车间</label>
                    <div class="layui-input-inline">
                        <input name="workshopName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label">描述</label>
                    <div class="layui-input-inline">
                        <input name="remark" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>

        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!--主柜权限-->
<script type="text/html" id="mainCabinetAuthorityForm">
    <form lay-filter="mainCabinetAuthorityForm" class="layui-form model-form  mainCabinetAuthorityForm">
        <div class="layui-row">
            <div class="layui-inline">
                <label class="layui-form-label">输入权限组名称：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入权限组名称" name="name" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline" style="padding-left: 10px;">
                <button class="layui-btn icon-btn color-green" type="button" lay-filter="mainCabinetAuthorityFormSearch"
                        lay-submit>
                    <i class="layui-icon layui-icon-search"></i>查询
                </button>
                <button class="layui-btn" type="button" id="addPermissionsGroupBtn">
                    <i class="layui-icon layui-icon-addition"></i>添加
                </button>
                <button class="layui-btn" type="button" id="permissionsExport">导出数据</button>
                <!--                <button class="layui-btn layui-btn-danger" type="button" lay-filter="">批量删除</button>-->
            </div>
        </div>
        <div class="open-details-box">
            <table class="layui-table" id="mainCabinetAuthorityTable" lay-filter="mainCabinetAuthorityTable"></table>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        </div>
    </form>
</script>

<!--权限弹窗操作列-->
<!--mainCabinetAuthorityFormTableBar-->
<script type="text/html" id="mainCabinetAuthorityFormTableBar">
    <a class="layui-btn layui-btn-xs layui-btn-primary" lay-event="details">详情</a>
    <a class="layui-btn layui-btn-xs" lay-event="modify">修改</a>
    <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="member">成员管理</a>
    {{# if(d.status =='0'){ }}
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="disable">禁用</a>
    {{# }else{ }}
    <a class="layui-btn layui-btn-xs" lay-event="enable">启用</a>
    {{# } }}

    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
</script>

<!--（添加、修改、详情）权限组-->
<!--addPermissionsGroup-->
<script type="text/html" id="addPermissionsGroupForm">
    <form lay-filter="addPermissionsGroupForm" class="layui-form model-form"
          style="padding: 5px 10px 0;height: calc(100% - 5px);overflow: hidden;">
        <div class="open-details-box"
             style="height: calc(100% - 65px); overflow-y: scroll; overflow-x: hidden; padding-top: 15px;">
            <input name="id" type="hidden" class="layui-input"/>
            <div class="layui-row layui-col-space20">
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">权限组名称</label>
                    <div class="layui-input-inline">
                        <input name="name" type="text" class="layui-input" placeholder="权限组名称"
                               lay-reqText="请输入权限组名称" lay-verify="required" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">是否启用</label>
                    <div class="layui-input-block">
                        <input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest"
                               lay-text="启用|不启用">
                    </div>
                </div>

                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">领新授信类型</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="creditType" value="money" title="金额" checked=""
                               lay-filter="creditType">
                        <input type="radio" name="creditType" value="quantity" title="数量" lay-filter="creditType">
                    </div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">授信方式</label>
                    <div class="layui-input-inline">
                        <select name="creditWay" lay-verify="required" lay-reqText="请选择授信方式" lay-filter="creditWay">
                            <option value="">请选择授信方式</option>
                            <option value="share">组员共享领用金额</option>
                            <option value="independent">组员独立授信领用金额</option>
                            <option value="unlimited">不限制领用金额</option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline layui-col-md6" id="moneyThresholdBox">
                    <label class="layui-form-label">未归还金额阈值</label>
                    <div class="layui-input-inline">
                        <input name="moneyThreshold" type="text" class="layui-input" placeholder="请输入金额"
                               lay-verify="required" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
                    </div>
                </div>
                <div class="layui-inline layui-col-md6" id="quantityThresholdBox" style="display: none">
                    <label class="layui-form-label">未归还数量阈值</label>
                    <div class="layui-input-inline">
                        <input name="quantityThreshold" type="text" class="layui-input" placeholder="请输入数量"
                               onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')"/>
                    </div>
                </div>


                <div class="layui-inline layui-col-md6" id="lineOfCreditBox">
                    <label class="layui-form-label">物料金额限制阈值</label>
                    <div class="layui-input-inline">
                        <input name="lineOfCredit" type="text" class="layui-input" placeholder="物料金额限制阈值"
                               id="lineOfCredit" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" lay-verify="required"/>
                    </div>
                </div>
                <div class="layui-inline layui-col-md6" style="display: none;" id="authorizedQuantityBox">
                    <label class="layui-form-label">物料数量限制阈值</label>
                    <div class="layui-input-inline">
                        <input name="authorizedQuantity" type="text" class="layui-input" placeholder="请输入物料数量限制阈值"
                               id="authorizedQuantity" onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" />
                    </div>
                </div>
                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">额度评估周期</label>
                    <div class="layui-input-inline">
                        <select name="lineEvaluatePeriod" lay-verify="required" lay-reqText="请选择额度评估周期">
                            <option value="">请选择额度评估周期</option>
                            <option value="day">每天</option>
                            <option value="week">每周</option>
                            <option value="month">每月</option>
                            <option value="quarter">每季度</option>
                            <option value="year">每年</option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline layui-col-md6" id="astrictMaterialBox">
                    <label class="layui-form-label">管控物资范围</label>
                    <div class="layui-input-inline">
                        <select name="astrictMaterial" lay-verify="required" lay-reqText="请选择是否限制物料"
                                lay-filter="astrictMaterial">
                            <option value="astrict">指定物料</option>
                            <option value="noAstrict">所有物料</option>
                        </select>
                    </div>

                </div>
                <div class="layui-inline layui-col-md6" id="restrictWayBox">
                    <label class="layui-form-label">添加方式</label>
                    <div class="layui-input-inline">
                        <input type="radio" name="restrictWay" value="category" title="按分类限制" checked=""
                               lay-filter="materiel">
                        <input type="radio" name="restrictWay" value="materiel" title="按物料限制" lay-filter="materiel">
                    </div>
                </div>

                <div class="layui-inline layui-col-md6" id="materialIdBox">
                    <label class="layui-form-label">管控物资分类</label>
                    <input name="materialId" type="hidden" class="layui-input"/>
                    <div class="layui-input-inline" id="materialId" style="width: 280px;"></div>
                </div>
                <!--<div class="layui-inline layui-col-md6" id="restrictNumberBox">
                    <label class="layui-form-label">物料限制阈值</label>
                    <div class="layui-input-inline">
                        <input name="restrictNumber" type="text" class="layui-input" placeholder="请输入阈值" lay-verify="required"
                               onkeyup="value=value.replace(/^(0+)|[^\d]+/g,'')" id="restrictNumber"/>
                    </div>
                </div>-->

                <div class="layui-inline layui-col-md6">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-inline">
                        <input name="remark" type="text" class="layui-input" placeholder="备注"/>
                    </div>
                </div>

            </div>
            <div class="layui-form-item" style="display: flex;align-items: center;justify-content: space-between;">
                <div class="color-title" style="flex: 1">SKU限制数</div>
                <button class="layui-btn color-green" type="button" id="addPermissionsGroupAdd" style="display: none">添加限制物料</button>
            </div>
            <div id="addPermissionsGroupFormTableBox">
                <table class="layui-table" id="addPermissionsGroupFormTable"
                       lay-filter="addPermissionsGroupFormTable"></table>
            </div>
            <!--<div class="layui-form-item">
                <label class="layui-form-label">权限组名称</label>
                <div class="layui-input-block">
                    <input name="name" type="text" class="layui-input" placeholder="权限组名称"
                           lay-reqText="请输入权限组名称" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">授信类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="creditType" value="money" title="金额" checked="" lay-filter="creditType">
                    <input type="radio" name="creditType" value="quantity" title="数量" lay-filter="creditType">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">授信方式</label>
                <div class="layui-input-block">
                    <select name="creditWay" lay-verify="required" lay-reqText="请选择授信方式" lay-filter="creditWay">
                        <option value="">请选择授信方式</option>
                        <option value="share">组员共享领用金额</option>
                        <option value="independent">组员独立授信领用金额</option>
                        <option value="unlimited">不限制领用金额</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" id="lineOfCreditBox">
                <label class="layui-form-label">授信额度</label>
                <div class="layui-input-block">
                    <input name="lineOfCredit" type="text" class="layui-input" placeholder="请输入授信额度"
                           lay-verify="number" id="lineOfCredit"/>
                </div>
            </div>
            <div class="layui-form-item" id="authorizedQuantityBox" style="display: none">
                <label class="layui-form-label">授信数量</label>
                <div class="layui-input-block">
                    <input name="authorizedQuantity" type="text" class="layui-input" placeholder="请输入授信数量"
                           lay-verify="number" id="authorizedQuantity"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">额度评估周期</label>
                <div class="layui-input-block">
                    <select name="lineEvaluatePeriod" lay-verify="required" lay-reqText="请选择额度评估周期">
                        <option value="">请选择额度评估周期</option>
                        <option value="day">每天</option>
                        <option value="week">每周</option>
                        <option value="month">每月</option>
                        <option value="quarter">每季度</option>
                        <option value="year">每年</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否限制物料</label>
                <div class="layui-input-block">
                    <select name="astrictMaterial" lay-verify="required" lay-reqText="请选择是否限制物料"
                            lay-filter="astrictMaterial">
                        <option value="noAstrict">不限制</option>
                        <option value="astrict">限制</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item" style="display: none" id="materialIdBox">
                <label class="layui-form-label">可领物资分类</label>
                <input name="materialId" type="hidden" class="layui-input"/>
                <div class="layui-input-block" id="materialId"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否启用</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="status" lay-skin="switch" lay-filter="switchTest"
                           lay-text="启用|不启用">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input name="remark" type="text" class="layui-input" placeholder="备注"/>
                </div>
            </div>-->
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="addPermissionsGroupFormSubmit" lay-submit type="button">保存</button>
        </div>
    </form>
</script>

<!--权限组操作-->
<!--addPermissionsGroupFormTableBar-->
<script type="text/html" id="addPermissionsGroupFormTableBar">
    {{# if(d.colsIsShow){ }}
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
    {{# }else{ }}
    {{# } }}
</script>

<!--添加限制物料-->
<!--addRestrictedMaterials-->
<script type="text/html" id="addRestrictedMaterialsTemplate">
    <div lay-filter="addRestrictedMaterialsForm" class="layui-form model-form"
         style="padding: 15px 10px 0;height: calc(100% - 15px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 65px); overflow-y: auto;">
            <div class="layui-row">
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">物料名称</label>
                    <div class="layui-input-inline">
                        <input name="skuName" type="text" class="layui-input" placeholder="请输入物料名称" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">物料编号</label>
                    <div class="layui-input-inline">
                        <input name="skuCode" type="text" class="layui-input" placeholder="请输入物料编号" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">规格码</label>
                    <div class="layui-input-inline">
                        <input name="oldSpecCode" type="text" class="layui-input" placeholder="请输入规格码" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label w-auto">品牌</label>
                    <div class="layui-input-inline">
                        <input name="productBrandName" type="text" class="layui-input" placeholder="请输入品牌" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn icon-btn color-green"
                            lay-filter="addRestrictedMaterialsFormSearch" lay-submit layui-form-keyDownSearch="true"><i
                            class="layui-icon layui-icon-search"></i>查询
                    </button>
                </div>
            </div>
            <div class="layui-form-item">
                <table class="layui-table" id="addRestrictedMaterialsFormTable"
                       lay-filter="addRestrictedMaterialsFormTable"></table>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="addRestrictedMaterialsFormSubmit" lay-submit id="addRestrictedMaterialsFormSubmit">保存</button>
        </div>
    </div>
</script>

<!--成员管理-->
<!--memberForm-->
<script type="text/html" id="memberForm">
    <div lay-filter="memberForm" class="layui-form model-form"
          style="padding: 20px 20px 0;height: calc(100% - 20px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 65px); overflow-y: auto;">
            <div class="layui-row">
                <label class="layui-form-label w-auto">成员姓名</label>
                <div class="layui-input-inline">
                    <input name="userName" type="text" class="layui-input" placeholder="输入成员姓名"/>
                </div>
                <div class="layui-inline" style="padding-left: 10px;">
                    <button type="button" class="layui-btn icon-btn color-green"
                            lay-filter="memberFormSearch" lay-submit ><i class="layui-icon layui-icon-search" layui-form-keyDownSearch="true"></i>查询
                    </button>
                    <button type="button" class="layui-btn icon-btn" id="addMembersBtn">添加成员</button>
                    <button type="button" class="layui-btn icon-btn" id="memberFormExport">导出数据</button>
                    <button type="button" class="layui-btn icon-btn layui-btn-danger" id="memberFormBatchDeletion">批量删除
                    </button>
                </div>
            </div>
            <div class="layui-form-item">
                <table class="layui-table" id="memberFormTable" lay-filter="memberFormTable"></table>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <!--            <button class="layui-btn" lay-filter="memberFormFormSubmit" lay-submit>保存</button>-->
        </div>
    </div>
</script>


<!--成员管理操作列-->
<!--memberFormBar-->
<script type="text/html" id="memberFormTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="details">详情</a>
    <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="delete">删除</a>
</script>

<!--添加权限组成员-->
<!--addPermissionGroupMembers-->
<script type="text/html" id="addPermissionGroupMembers">
    <div lay-filter="addPermissionGroupMembersForm" class="layui-form model-form"
          style="padding: 5px 20px 0;height: calc(100% - 5px);overflow: hidden;" id="addPermissionGroupMembersForm">
        <div class="open-details-box"
             style="height: calc(100% - 65px); overflow-y: auto; overflow-x: hidden; padding-top: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">权限组名称</label>
                <div class="layui-input-block">
                    <input name="name" type="text" class="layui-input" style="border-color: transparent" disabled/>
                </div>
            </div>
            <div class="layui-form-item" id="addPermissionGroupMembersFormLineOfCreditBox" style="display: none">
                <label class="layui-form-label">授权额度</label>
                <div class="layui-input-block">
                    <input name="lineOfCredit" type="text" class="layui-input" style="border-color: transparent"
                           disabled/>
                </div>
            </div>
            <div class="layui-form-item" id="addPermissionGroupMembersFormAuthorizedQuantityBox" style="display: none">
                <label class="layui-form-label">授权数量</label>
                <div class="layui-input-block">
                    <input name="authorizedQuantity" type="text" class="layui-input" style="border-color: transparent"
                           disabled/>
                </div>
            </div>


            <div class="layui-form-item" id="materialId1Box" style="display: none">
                <label class="layui-form-label">可领物资分类</label>
                <input name="materialId" type="hidden"/>
                <div class="layui-input-block" id="materialId1"></div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">选择人员</label>
                <div class="layui-input-block" id="userIdBox"></div>
                <div class="layui-input-block addPermissionGroupMembersDetail">
                    <input type="text" name="userName" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item addPermissionGroupMembersDetail">
                <label class="layui-form-label">选择企业</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="enterpriseName" disabled>
                </div>
            </div>
            <div class="layui-form-item addPermissionGroupMembersDetail">
                <label class="layui-form-label">选择部门</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="deptName" disabled>
                </div>
            </div>

            <div class="layui-form-item addPermissionGroupMembersDetail">
                <label class="layui-form-label">选择岗位</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" name="positionName" disabled>
                </div>
            </div>

            <div class="layui-form-item addPermissionGroupMembersDetail">
                <label class="layui-form-label">工号</label>
                <div class="layui-input-block">
                    <input name="jobNumber" type="text" class="layui-input" disabled/>
                </div>
            </div>
            <div class="layui-form-item addPermissionGroupMembersDetail">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input name="phone" type="text" class="layui-input" disabled/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">是否启用</label>
                <div class="layui-input-block">
                    <input type="checkbox" checked="" name="isDeleted" lay-skin="switch" lay-filter="switchTest"
                           lay-text="启用|不启用">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input name="remark" type="text" class="layui-input" placeholder="备注"/>
                </div>
            </div>
        </div>

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="addPermissionGroupMembersFormSubmit" lay-submit>保存</button>
        </div>
    </div>
</script>



<!--主柜货道-->
<script type="text/html" id="mainCabinetCargoForm">
    <div lay-filter="mainCabinetCargoForm" class="layui-form model-form  mainCabinetCargoForm">
        <div class="layui-form-item mainCabinetCargoFormHeader">
            <div class="layui-inline">
                <label class="layui-form-label">货道编号：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入货道编号" name="code">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">物料名称：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="物料名称" name="skuName">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn" type="button" lay-filter="mainCabinetCargoSearch" lay-submit layui-form-keyDownSearch="true">
                    <i class="layui-icon layui-icon-search"></i>查询
                </button>
                <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit type="button">重置</button>
            </div>
        </div>
        <div class="open-details-box">
            <div class="cargoBox layui-clear" id="cargoBox">
                <!--<div class="cargoBoxItem">
                    <div class="cargoBoxItemContent">
                        <div class="cargoBoxItemImage">
                            <div class="cargoBoxItemImageTitle">货道编号</div>
                            <img src="https://product-1312272031.cos.ap-nanjing.myqcloud.com/02.png" alt="">
                        </div>
                        <div class="cargoBoxItemInfo">
                            <div class="cargoBoxItemInfoTitle">物料名称</div>
                            <div class="cargoBoxItemInfo1" title="物料编号">物料编号</div>
                            <div class="cargoBoxItemInfo1">品牌</div>
                            <div class="cargoBoxItemInfo1">库存数量</div>
                            <div class="cargoBoxItemInfo1">货道容量</div>
                        </div>
                    </div>
                    <div class="cargoBoxItemInfoEdit">
                        <i class="layui-icon layui-icon-edit"></i>修改参数
                    </div>
                </div>
                <div class="cargoBoxItem">
                    <div class="cargoBoxItemContent">
                        <div class="cargoBoxItemImage">
                            <div class="cargoBoxItemImageTitle noImg">货道编号</div>
                            <img src="assets/images/cabinet/noCargo.png" alt="">
                        </div>
                        <div class="cargoBoxItemInfo">
                            <div class="cargoBoxItemInfoTitle">物料名称</div>
                            <div class="cargoBoxItemInfo1" title="物料编号">物料编号</div>
                            <div class="cargoBoxItemInfo1">品牌</div>
                            <div class="cargoBoxItemInfo1">库存数量</div>
                            <div class="cargoBoxItemInfo1">货道容量</div>
                        </div>
                    </div>
                    <div class="cargoBoxItemInfoEdit">
                        <i class="layui-icon layui-icon-edit"></i>修改参数
                    </div>
                </div>-->
            </div>
            <div class="cargoPage" id="cargoPage" style="text-align: right"></div>
        </div>
    </div>
</script>

<!--货道  参数修改-->
<script type="text/html" id="cargoLanelModifyForm">
    <div class="layui-card">
        <div class="cargoLanelModifyForm">
            <form lay-filter="cargoLanelModifyForm" class="layui-form model-form">
                <input name="id" type="hidden"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">库存容量</label>
                    <div class="layui-input-block" style="margin-left: 150px;">
                        <input name="quantity" type="number" class="layui-input" id="quantity"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">存放备注提示</label>
                    <div class="layui-input-block" style="margin-left: 150px;">
                        <input name="remark" type="text" class="layui-input"/>
                    </div>
                </div>
                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" type="button" id="cargoLanelModifyFormSubmit"
                            lay-filter="cargoLanelModifyFormSubmit" lay-submit>提交
                    </button>
                </div>
            </form>
        </div>
    </div>
</script>

<!--主柜暂存柜-->
<script type="text/html" id="mainCabinetStagingForm">
    <div lay-filter="mainCabinetStagingForm" class="layui-form model-form  mainCabinetStagingForm">
        <div class="layui-form-item">
            <div class="layui-inline" id="mainCabinetStagingFormCabCodeBox">
                <label class="layui-form-label">柜子编号：</label>
                <div class="layui-input-inline">
                    <!--                    <input type="text" class="layui-input" placeholder="柜子编号" name="cabCode">-->
                    <select name="cabCode"></select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">货位编号：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="货位编号" name="code">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">货位状态：</label>
                <div class="layui-input-inline">
                    <select name="businessStatus">
                        <option value="">请选择货位状态</option>
                        <option value="normal">正常</option>
                        <option value="abnormal">异常</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" style="display: none">
                <label class="layui-form-label">货位性质：</label>
                <div class="layui-input-inline">
                    <select name="spaceNature">
                        <option value="">请选择货位性质</option>
                        <option value="personal">专人存储</option>
                        <option value="specialClass">专类存储</option>
                        <option value="sku">按物料</option>
                        <option value="common">公共存储</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn" type="button" lay-filter="mainCabinetStagingSearch" lay-submit layui-form-keyDownSearch="true">
                    <i class="layui-icon layui-icon-search"></i>查询
                </button>
            </div>
        </div>
        <div class="open-details-box">
            <div class="stagingBox layui-clear" id="stagingBox">
                <!--                <div class="stagingBoxItem">-->
                <!--                    <div class="stagingBoxItemHeader stagingBoxItemHeaderBg1">柜子名称+货位号</div>-->
                <!--                    <div class="stagingBoxItemMain">-->
                <!--                        <div class="stagingBoxItemTitle">性质：<span>专人存储</span></div>-->
                <!--                        <div class="stagingBoxItemInfo">所属人员：<span>admin(ID:001)</span></div>-->
                <!--                        <div class="stagingBoxItemInfo">物料类型：<span>不限</span></div>-->
                <!--                        <div class="stagingBoxItemInfo">物料数：<span>5个</span></div>-->
                <!--                        <div class="stagingBoxItemInfo">库存数量：<span>20</span></div>-->
                <!--                        <div class="stagingBoxItemInfo">货位状态：<span>使用中</span></div>-->
                <!--                    </div>-->
                <!--                    <div class="stagingBoxItemFooter">-->
                <!--                        <div class="stagingBoxItemFooterEdit"><i class="layui-icon layui-icon-edit"></i>修改参数</div>-->
                <!--                        <div class="stagingBoxItemFooterDetailed"><i class="layui-icon layui-icon-list"></i>库存明细</div>-->
                <!--                    </div>-->
                <!--                </div>-->
            </div>
            <div class="cargoPage" id="stagingPage" style="text-align: right"></div>
        </div>
    </div>
</script>

<!--暂存柜库存明细-->
<script type="text/html" id="mainCabinetStagingDetailedForm">
    <form lay-filter="mainCabinetStagingDetailedForm" class="layui-form model-form  mainCabinetStagingDetailedForm">
        <div class="open-details-box">
            <table class="layui-table" id="mainCabinetStagingDetailedTable"
                   lay-filter="mainCabinetStagingDetailedTable"></table>
        </div>
    </form>
</script>

<!-- 供货位参数设置--》修改 -->
<!--supplyParametersModifyForm-->
<script type="text/html" id="supplyParametersModifyForm">
    <form lay-filter="supplyParametersModifyForm" class="layui-form model-form">
        <div class="layui-form-item">
            <label class="layui-form-label">柜子编号</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input noBorder" name="cabCode" readonly disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">货位编号</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input noBorder" name="spaceCode" readonly disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">货位状态</label>
            <div class="layui-input-block ">
                <select name="businessStatus" lay-verify="required">
                    <option value="">请选择</option>
                    <option value="normal">正常</option>
                    <option value="abnormal">异常</option>
                </select>
            </div>
        </div>
        <!--
        <div class="layui-form-item">
            <label class="layui-form-label">货位性质</label>
            <div class="layui-input-inline ">
                <select name="spaceNature" lay-verify="required" lay-filter="supplyParametersModifySpaceNature">
                    <option value="">请选择</option>
                    <option value="personal">专人存储</option>
                    <option value="common">公共存储</option>
                    <option value="specialClass">专类存储</option>
                    <option value="sku">按SKU</option>
                    <option value="repair">盘验前报修存储</option>
                    <option value="recycle">盘验前报废存储</option>
                    <option value="repairChecked">盘验后报修存储</option>
                    <option value="recycleChecked">盘验后报废存储</option>
                </select>
            </div>
        </div>
        -->
        <div class="layui-form-item">
            <label class="layui-form-label">货位性质</label>
            <div class="layui-input-block ">
                <select name="spaceType" lay-verify="" lay-filter="supplyParametersModifySpaceNature">
                    <option value="common">通用</option>
                    <option value="temp">暂存</option>
                    <option value="repair">报修</option>
                    <option value="recycle">报废</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item" id="spaceProductTypeBox" style="display: block">
            <label class="layui-form-label">物料类型</label>
            <div class="layui-input-block ">
                <select name="spaceProductType" lay-verify="" lay-filter="spaceProductType"
                        id="spaceProductType"></select>
            </div>
        </div>
        <div class="layui-form-item" id="skuCodeBox" style="display: block">
            <label class="layui-form-label">物料编号</label>
            <div class="layui-input-block">
                <select name="skuCode" id="skuCode" lay-filter="skuCode" lay-verify="" lay-search required></select>
            </div>
        </div>
        <div class="layui-form-item" id="principalBox" style="display: block">
            <label class="layui-form-label">专人</label>
            <div class="layui-input-block ">
                <div id="principal"></div>
                <!--                <select name="principal" lay-verify="" lay-filter="principal" id="principal"></select>-->
                <input type="hidden" name="principal">
                <input type="hidden" name="principalName">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">货位容量</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input" name="quantity">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input" name="remark">
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="supplyParametersModifyFormbtn" lay-submit="" type="button">保存
            </button>
        </div>
    </form>
</script>

<!--主柜物料-->
<script type="text/html" id="mainCabinetProductForm">
    <div lay-filter="mainCabinetProductForm" class="layui-form model-form  mainCabinetProductForm">
        <div class="layui-row" style="display: flex">
            <div class="layui-inline">
                <label class="layui-form-label">物料名称：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入物料名称" name="skuName" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">物料编号：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入物料编号" name="skuCode" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">规格码：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入规格码" name="skuSpecOld" autocomplete="off"/>
                </div>
            </div>
            <div class="layui-inline" style="margin-left: 10px">
                <button class="layui-btn" type="button" lay-filter="mainCabinetProductSearch" lay-submit layui-form-keyDownSearch="true">
                    <i class="layui-icon layui-icon-search"></i>查询
                </button>
            </div>
            <div class="layui-inline" style="margin-left: auto">
                <button class="layui-btn" type="button" id="mainCabinetProductFormExport">导出</button>
            </div>
        </div>
        <div style="height: calc(100% - 40px);overflow: auto;">
            <table class="layui-table" id="mainCabinetProductTable" lay-filter="mainCabinetProductTable"></table>
        </div>
    </div>
</script>

<!-- 物料操作 -->
<script type="text/html" id="productTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="distributionCargoWayBtn">货道分布详情</a><br>
    {{# if(d.cabinetNature =='main'){  }}
    <a class="layui-btn layui-btn-xs" lay-event="alarmSettingBtn">缺料告警设置</a>
    {{# } }}
</script>

<!-- 物料（分布货道） -->
<!-- DistributionCargoWay -->
<script type="text/html" id="distributionCargoWay">
    <div>
        <div class="layui-card-body">
            <table class="layui-table" id="distributionCargoWayTable" lay-filter="distributionCargoWayTable"></table>
        </div>
    </div>
</script>
<!-- 物料（告警设置） -->
<!-- alarmSetting -->
<script type="text/html" id="alarmSetting">
    <form class="layui-form model-form alarmSettingForm" lay-filter="alarmSettingForm">
        <input type="hidden" name="id">
        <div class="layui-form-item">
            <label class="layui-form-label">柜子编号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input noBorder" name="cabCode" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所在位置</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input noBorder" name="location" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">物料</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input noBorder" name="productName" readonly>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">规格号</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input noBorder" name="specCode" readonly>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">缺料告警阈值</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="alarmStock" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最低补货目标</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input" name="planReplenishment">
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">归还时长阈值</label>
            <div class="layui-input-block ">
                <input name="thresholdBlack" min="0" type="number" class="layui-input"/>
            </div>

        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">询问线</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input" name="proposalStock">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block ">
                <input type="text" class="layui-input" placeholder="备注" name="remarks">
            </div>
        </div>
        <!-- <div class="layui-form-item">
             <label class="layui-form-label">设置时间</label>
             <div class="layui-input-inline ">
                 <input name="setTime" type="datetime-local" class="layui-input noBorder" readonly/>
             </div>
         </div>-->

        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="alarmSettingSubBtn" lay-submit type="button">提交保存</button>
        </div>
    </form>
</script>

<!--主柜订单-->
<script type="text/html" id="mainCabinetOrderForm">
    <div lay-filter="mainCabinetOrderForm" class="layui-form model-form  mainCabinetOrderForm">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">输入订单编号：</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" placeholder="请输入订单编号" name="code" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn" type="button" lay-filter="mainCabinetOrderSearch" lay-submit layui-form-keyDownSearch="true">
                    <i class="layui-icon layui-icon-search"></i>查询
                </button>
            </div>
        </div>
        <div class="open-details-box">
            <div class="mainCabinetOrderBox" id="mainCabinetOrderBox">
                <!--<div class="mainCabinetOrderItem">
                    <div class="mainCabinetOrderItemHeader">
                        <div class="mainCabinetOrderItemCode">订单编：123565648156</div>
                        <div class="mainCabinetOrderItemNum">30</div>
                    </div>
                    <div class="mainCabinetOrderItemCenter">
                        <div class="mainCabinetOrderItemImg">
                            <div></div>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>智能柜</p>
                            <p>物料名称</p>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>121212</p>
                            <p>物料SKU码</p>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>云端</p>
                            <p>品牌</p>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>12</p>
                            <p>领取数量</p>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>sd-123</p>
                            <p>柜子</p>
                        </div>
                        <div class="mainCabinetOrderItemInfo">
                            <p>程东</p>
                            <p>领取人</p>
                        </div>
                        <div class="mainCabinetOrderItemBtn">
                            <a class="layui-btn layui-btn-primary layui-btn-xs mainCabinetOrderItemBtnDetails">详情</a>
                        </div>
                    </div>
                </div>-->
            </div>
            <div class="mainCabinetOrderPage" id="mainCabinetOrderPage" style="text-align: right"></div>
        </div>
    </div>
</script>


<!--主柜订单详情-->
<script type="text/html" id="mainCabinetOrderDetailsForm">
    <form lay-filter="mainCabinetOrderDetailsForm" class="layui-form model-form mainCabinetOrderDetailsForm">
        <div class=layui-row">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">订单编号</label>
                    <div class="layui-input-inline">
                        <input name="code" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">柜子编号</label>
                    <div class="layui-input-inline">
                        <input name="cabCode" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">物料名称</label>
                    <div class="layui-input-inline">
                        <input name="skuName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">物料图片</label>
                    <div class="layui-input-inline">
                        <input name="skuPic" type="hidden" class="layui-input" readonly="true"/>
                        <div class="imgBox" id="mainCabinetOrderDetailsSkuPic"></div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">物料编号</label>
                    <div class="layui-input-inline">
                        <input name="skuCode" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>

            </div>

            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <label class="layui-form-label">规格码</label>
                    <div class="layui-input-inline">
                        <input name="skuSpecOld" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                     <label class="layui-form-label">旧规格码</label>
                     <div class="layui-input-inline">
                         <input name="skuSpec" type="text" class="layui-input" readonly="true"/>
                     </div>
                 </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">货道</label>
                    <div class="layui-input-inline">
                        <input name="spaceCode" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">市场价</label>
                    <div class="layui-input-inline">
                        <input name="marketPrice" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">数量</label>
                    <div class="layui-input-inline">
                        <input name="quantity" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <!-- <div class="layui-form-item">
                     <label class="layui-form-label">领取操作员</label>
                     <div class="layui-input-inline">
                         <input name="modifierName" type="text" class="layui-input" readonly="true"/>
                     </div>
                 </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">领取人</label>
                    <div class="layui-input-inline">
                        <input name="creatorName" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">订单提交时间</label>
                    <div class="layui-input-inline">
                        <input name="createTime" type="text" class="layui-input" readonly="true"/>
                    </div>
                </div>
            </div>
        </div>
    </form>
</script>

<!--主柜修改-->
<script type="text/html" id="mainCabinetModifyForm">
    <form lay-filter="mainCabinetModifyForm" class="layui-form model-form mainCabinetModifyForm">
        <div class="open-details-box">
            <input name="id" type="hidden"/>
            <div class="layui-form-item">
                <label class="layui-form-label">企业自定义名称</label>
                <div class="layui-input-inline">
                    <input name="cabName" type="text" class="layui-input" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属企业</label>
                <div class="layui-input-inline">
                    <select name="settledCompanyId" lay-filter="settledCompanyId" lay-verify="required"
                            lay-search></select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">客户所在地</label>
                <div class="layui-input-inline">
                    <input name="workshopLocation" type="text" class="layui-input" lay-verify="required"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属车间</label>
                <div class="layui-input-inline">
                    <select name="workshopId" lay-filter="workshopId" lay-search></select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-inline">
                    <input name="remark" type="text" class="layui-input"/>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="mainCabinetModifyFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!--副柜转移-->
<script type="text/html" id="transferForm">
    <form lay-filter="transferForm" class="layui-form model-form transferForm">
        <div class="open-details-box">
            <input name="id" type="hidden"/>
            <div class="layui-form-item">
                <label class="layui-form-label">当前主柜编号</label>
                <div class="layui-input-inline">
                    <input name="" type="text" class="layui-input" readonly id="transferFrom"/>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">*目标主柜编号</label>
                <div class="layui-input-inline">
                    <select name="belongCabinet" lay-verify="required" lay-search id="transferTo"></select>
                </div>
            </div>
        </div>
        <div class="layui-form-item text-center">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="transferFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>


<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laypage'], function () {
        let $ = layui.jquery, layer = layui.layer, form = layui.form, table = layui.table, config = layui.config,
            admin = layui.admin, laypage = layui.laypage;
        let cabinetId = '';

        init();

        // 入口文件
        function init() {
            getMainData()
        }

        // 请求主柜数据
        function getMainData() {
            admin.req('enterprisecab/cabinet/admin/cabinet/list', {
                    cabinetNature: 'main',
                    cabinetTypeId: "",
                    cabinetBrandId: "",
                    status: "",
                    code: "",
                    cabinetType: "spring"
                },
                res => {
                    if (res.code === 200) {
                        showMainHtml(res.data)
                    } else {
                        showMainHtml([])
                    }
                }
            )
        }

        // 渲染主柜
        function showMainHtml(_data) {
            if (!_data || _data.length === 0) {
                $('#mainHeaderTitleNum').html('(0)');
                $('#mainBoxList').html('<h3 class="noData">暂无内容~~~</h3>');
                return false;
            }
            let html = '';
            _data.forEach((item, index) => {
                if (index === 0) {
                    html += `<div class="mainBoxItem active" data='${JSON.stringify(item)}'>`;
                    /*请求对应的副柜数据*/
                    getAuxiliaryData(item)
                } else {
                    html += `<div class="mainBoxItem" data='${JSON.stringify(item)}'>`;
                }
                html += `
                        <div class="mainBoxContent">
                            <div class="mainBoxContentImg"><img src="assets/images/cabinet/cabinet.png"></div>
                            <div class="mainBoxContentRight">
                                <div class="mainBoxContentName">${item.name}(${item.cabName})</div>
                                <div class="mainBoxContentInfo">
                                    <div>主柜编号：<span>${item.cabCode}</span></div>
                                    <div>副柜数量：<span>${item.cabNum}</span></div>
                                </div>
                                <div class="mainBoxContentInfo">
                                    <div>货道数量：<span>${item.laneNum}</span></div>
                                    <div>物料数量：<span>${item.skuNum}</span></div>
                                </div>
                                <div class="mainBoxContentBtn">
                                    <div class="mainBoxContentButton details">详情</div>
                                    <!--<div class="mainBoxContentButton power">权限</div>-->
                                    <div class="mainBoxContentButton cargo">货道</div>
                                    <div class="mainBoxContentButton staging">货位</div>
                                    <div class="mainBoxContentButton product">物料</div>
                                    <div class="mainBoxContentButton order">订单</div>
                                    <div class="mainBoxContentButton modify">修改</div>
                                </div>
                            </div>
                        </div>
                    </div>`;
            });
            $('#mainHeaderTitleNum').html('(' + _data.length + ')');
            $('#mainBoxList').html(html);

        }

        // 请求副柜数据
        function getAuxiliaryData(_belongCabinet) {
            if (!_belongCabinet.cabCode) {
                showAuxiliaryHtml([]);
                return false
            }
            layer.load(2);
            admin.req('enterprisecab/cabinet/admin/cabinet/list', {
                    cabinetTypeId: "",
                    cabinetBrandId: "",
                    status: "",
                    code: "",
                    cabinetType: "spring",
                    belongCabinet: _belongCabinet.cabCode,
                    queryFlag: "query4setting"
                },
                res => {
                    layer.closeAll('loading');
                    if (res.code === 200) {
                        showAuxiliaryHtml(res.data)
                    } else {
                        showAuxiliaryHtml([])
                    }
                }
            )
        }

        // 渲染副柜
        function showAuxiliaryHtml(_data) {
            if (!_data || _data.length === 0) {
                $('#auxiliaryHeaderTitleNum').html('(0)');
                $('#auxiliaryBoxList').html('<h3 class="noData">暂无内容~~~</h3>');
                return false;
            }

            let html = '';
            _data.forEach((item, index) => {
                html += `<div class="auxiliaryBoxItem" data='${JSON.stringify(item)}'>
                                <div class="auxiliaryBoxItemImg"><img src="assets/images/cabinet/cabinet.png"></div>
                                <div class="auxiliaryBoxItemInfo">
                                    <div class="auxiliaryBoxItemInfoTitle">${item.code}(${item.cabName})</div>
                                    <div class="auxiliaryBoxItemInfo1">副柜名称：<span>${item.name}</span></div>
                                     <div class="auxiliaryBoxItemInfo1">刀柜性质：<span>${item.cabinetNatureDesc}</span></div>
                                    <div class="auxiliaryBoxItemInfo1">${item.cabinetNature == 'sale' ? '货道数量：' : '货位数量：'}<span> ${item.cabinetNature == 'sale' ? item.laneNum : item.spaceNum} 个</span></div>
                                    <div class="auxiliaryBoxItemInfo1">物料数量：<span>${item.skuNum}个</span></div>
                                </div>
                                <div class="auxiliaryBoxItemBtn">
                                    <a class="layui-btn layui-btn-primary layui-btn-xs details">详情</a>
                                    ${item.cabinetNature == 'sale' ? '<a class="layui-btn layui-btn-xs cargo">货道</a>' : '<a class="layui-btn layui-btn-xs staging">货位</a>'}
                                    <a class="layui-btn layui-btn-xs product">物料</a>
                                    <a class="layui-btn layui-btn-xs order">订单</a>
                                    <a class="layui-btn layui-btn-xs modify">修改</a>
                                    <a class="layui-btn layui-btn-xs layui-btn-danger transfer">转移</a>
                                </div>
                            </div>`
            });
            $('#auxiliaryHeaderTitleNum').html('(' + _data.length + ')');
            $('#auxiliaryBoxList').html(html);
        }

        /*主柜点击事件*/
        $('#mainBoxList').delegate('.mainBoxItem', 'click', function () {
            if ($(this).is('.active')) return false;
            $(this).addClass('active').siblings().removeClass('active');
            getAuxiliaryData(JSON.parse($(this).attr('data')));
        });

        /*主柜详情点击事件*/
        $('#mainBoxList').delegate('.details', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            detailsPop(data);
        });

        /*副柜详情点击事件*/
        $('#auxiliaryBoxList').delegate('.details', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            detailsPop(data);
        });

        /*主柜详情弹窗*/
        function detailsPop(data) {
            admin.open({
                type: 1,
                area: ['1200px', '600px'],
                offset: '65px',
                title: '详情',
                content: $('#mainCabinetDetailsForm').html(),
                success: function () {
                    if (data.cabinetNature == 'live') {
                        $('.laneNumBox').hide();
                    } else if (data.cabinetNature == 'sale') {
                        $('.spaceNumBox').hide();
                    }
                    layer.load(2);
                    admin.req('enterprisecab/cabinet/admin/cabinet/queryDetail',
                        {cabCode: data.cabCode, cabinetNature: data.cabinetNature == 'main' ? 'main' : ''}, res => {
                            layer.closeAll('loading');
                            if (res.code === 200) {
                                form.val('mainCabinetDetailsForm', res.data);
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        })
                }
            });
        }


        /*主柜权限点击事件*/
        $('#mainBoxList').delegate('.power', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            /*主柜权限弹窗*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            cabinetId = data.id;
            admin.open({
                type: 1,
                area: ['1200px', '810px'],
                offset: '65px',
                title: '设备权限管理',
                content: $('#mainCabinetAuthorityForm').html(),
                success: function () {
                    let mainCabinetAuthorityTb = table.render({
                        elem: '#mainCabinetAuthorityTable',
                        url: config.base + 'enterprisecab/cabinet/admin/authorityManage/list?cabinetId=' + data.id,
                        page: true,
                        cellMinWidth: 100,
                        title:'设备权限组列表',
                        id: 'mainCabinetAuthorityTable',
                        cols: [[
                            {type: 'checkbox'}
                            , {field: 'name', title: '权限组名称'}
                            , {field: 'quantity', title: '人员数量'}
                            , {
                                field: 'oldSpecCode', title: '物料限制阈值', width: 180,
                                templet: d => {
                                    if (d.creditType == "money") {
                                        if (d.creditWay == "unlimited") {
                                            return d.creditWayDesc + "元/" + d.lineEvaluatePeriodDesc
                                        } else {
                                            return d.lineOfCredit + "元/" + d.lineEvaluatePeriodDesc
                                        }
                                    } else {
                                        if (d.creditWay == "unlimitedQuantity") {
                                            return d.creditWayDesc + "/" + d.lineEvaluatePeriodDesc
                                        } else {
                                            return d.authorizedQuantity + "/" + d.lineEvaluatePeriodDesc
                                        }
                                    }
                                },
                            }
                            , {field: 'remark', title: '说明'}
                            , {field: 'status', title: '状态', templet: d => d.status == '0' ? '正常' : '禁用'}
                            , {field: 'createTime', title: '创建时间'}
                            , {toolbar: '#mainCabinetAuthorityFormTableBar', title: '操作', width: 300}
                        ]],
                        done: function (d) {
                        }
                    });

                    table.on('tool(mainCabinetAuthorityTable)', function (obj) {
                        let data = obj.data;
                        if (obj.event === 'details') { //详情
                            showAddPermissionsGroupForm(data, '', 'details');
                        } else if (obj.event === 'modify') { // 修改
                            showAddPermissionsGroupForm(data, '', 'modify');
                        } else if (obj.event === 'member') {  // 成员管理
                            showMemberForm(data)
                        } else if (obj.event === 'disable') { // 禁用
                            enableAndDisable('1', data)
                        } else if (obj.event === 'enable') {  //  启用
                            enableAndDisable('0', data)
                        }else if(obj.event === 'delete'){
                            layer.confirm('确定删除吗？', {
                                skin: 'layui-layer-admin'
                            }, function (i) {
                                layer.close(i);
                                layer.load(2);
                                admin.req('enterprisecab/cabinet/admin/authorityManage/' + data.id, {}, function (data) {
                                    layer.closeAll('loading');
                                    if (data.code == 200) {
                                        layer.msg(data.msg, {icon: 1});
                                        table.reload('mainCabinetAuthorityTable');
                                        layer.close(i);
                                    } else {
                                        layer.msg(data.msg, {icon: 2});
                                    }
                                }, 'DELETE');
                            });
                        }
                    });

                    function enableAndDisable(_type, _data) {
                        layer.load(2);
                        admin.req('enterprisecab/cabinet/admin/authorityManage/enable/' + _data.id + '/' + _type, {}, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('mainCabinetAuthorityTable');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'PUT');
                    }

                    $('#addPermissionsGroupBtn').click(function () { // 添加权限组
                        showAddPermissionsGroupForm(false, data)
                    });
                    $('#permissionsExport').click(function () {  //导出
                        let checkRows = table.checkStatus('mainCabinetAuthorityTable');
                        if (checkRows.data.length == 0) {
                            layer.msg('请选择要导出的数据', {icon: 2});
                        } else {
                            table.exportFile(mainCabinetAuthorityTb.config.id, checkRows.data, 'xls');
                        }
                    });

                    //搜索
                    form.on('submit(mainCabinetAuthorityFormSearch)', function (data) {
                        mainCabinetAuthorityTb.reload({where: data.field, page: {curr: 1}}, 'data');
                    });

                }
            });
        });


        // (添加、修改、详情)权限组
        function showAddPermissionsGroupForm(data, cabinetData, _type) {
            let addPermissionsGroupPopUp = admin.open({
                type: 1,
                area: ['1280px', '750px'],
                offset: '85px',
                title: _type ? (_type == 'details' ? '权限组详情' : '修改权限组') : '添加权限组',
                content: $('#addPermissionsGroupForm').html(),
                success: function (_data) {
                    let ids = undefined, categoryIds = undefined, authorityManageId = undefined;
                    let arr2treeExt;
                    let selectedData = function (treeData, targetId) {
                        for (var k = 0; k < treeData.length; k++) {
                            var nodeId = treeData[k].id;
                            if (targetId == nodeId) {
                                treeData[k].selected = true;
                                return;
                            } else {
                                if (treeData[k].children && treeData[k].children != '') {
                                    selectedData(treeData[k].children, targetId);
                                }
                            }
                        }
                    };
                    admin.req('enterprise/product/admin/productCategory/list?limit=9999&enterprise=0&page=1', {}, function (res) {
                        for (let i = 0; i < res.data.length; i++) {
                            res.data[i].children = [];
                        }
                        arr2treeExt = xmSelect.arr2tree(res.data, "parentId", "id", "children", -1);
                    }, 'get', false);

                    let selectedDataExt = function (treeData, targetId) {
                        var ids = targetId.split(",");
                        for (var k = 0; k < treeData.length; k++) {
                            var nodeId = treeData[k].id;
                            for (var t = 0; t < ids.length; t++) {
                                if (ids[t] == nodeId) {
                                    treeData[k].selected = true;
                                    continue;
                                } else {
                                    if (treeData[k].children && treeData[k].children != '') {
                                        selectedData(treeData[k].children, ids[t]);
                                    }
                                }
                            }
                        }
                    };

                    let addPermissionsGroupFormTbData = [];
                    let addPermissionsGroupFormTb = table.render({
                        elem: '#addPermissionsGroupFormTable',
                        data: addPermissionsGroupFormTbData,
                        cellMinWidth: 100,
                        limit: Number.MAX_VALUE,
                        cols: [[
                            {type: 'numbers', title: '序号', fixed: 'left'}
                            , {field: 'productPic',title: '图片',
                                templet: d => d.productPic ? '<img src="' + d.productPic + '" style="cursor: pointer"/>' : '<img src="assets/images/default-icon.png" style="cursor: pointer"/>'
                            }
                            , {field: 'skuName', title: '物料名称'}
                            , {field: 'skuCode', title: '物料编号'}
                            , {field: 'oldSpecCode', title: '物料规格'}
                            , {field: 'packName', title: '包装规格'}
                            , {field: 'productBrandName', title: '所属品牌'}
                            , {field: 'unitName', title: '单位'}
                            , {field: 'number', title: '限制数值' ,width:"150",
                                templet:d=> {
                                    if(d.number && d.number>0){
                                        return `<input name="number" class='layui-input' style="width: 120px;" type='text' onkeyup="value=value.replace(/^(0+)|[^\\d]+/g,'')" value="${d.number}"/>`
                                    }else {
                                        return `<input name="amount" class='layui-input' style="width: 120px;" type='text' onkeyup="value=value.replace(/^(0+)|[^\\d]+/g,'')" value="${d.amount}"/>`
                                    }
                                }}
                            , {align: 'center', toolbar: '#addPermissionsGroupFormTableBar', title: '操作'}
                        ]],
                        done:function (res, curr, count) {
                            if(_type == 'details'){
                                $('#addPermissionsGroupFormTableBox input').attr('disabled','disabled')
                            }
                        }
                    });

                    table.on('tool(addPermissionsGroupFormTable)', function (obj) {
                        let data = obj.data;
                        if (obj.event === 'delete') { // 删除
                            addPermissionsGroupFormTbData.splice($(obj.tr[0]).attr('data-index'),1);
                            table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                        }
                    });

                    $("#addPermissionsGroupFormTableBox").delegate("input[name='number']", "blur", function () {
                        if (addPermissionsGroupFormTbData[$(this).parents('tr').index()]) {
                            addPermissionsGroupFormTbData[$(this).parents('tr').index()].number = $(this).val();
                            addPermissionsGroupFormTbData[$(this).parents('tr').index()].amount = '';
                        }
                    });
                    $("#addPermissionsGroupFormTableBox").delegate("input[name='amount']", "blur", function () {
                        if (addPermissionsGroupFormTbData[$(this).parents('tr').index()]) {
                            addPermissionsGroupFormTbData[$(this).parents('tr').index()].amount = $(this).val();
                            addPermissionsGroupFormTbData[$(this).parents('tr').index()].number ='';
                        }
                    });


                    $('#lineOfCredit').blur(function () {
                        addPermissionsGroupFormTbData.forEach(item=>{
                            item.amount = $(this).val()
                        });

                        table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                    });

                    $('#authorizedQuantity').blur(function () {
                        addPermissionsGroupFormTbData.forEach(item=>{
                            item.number = $(this).val()
                        });
                        table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                    });

                    //领新授信类型选择
                    form.on('radio(creditType)', function (data) {
                        creditType(data.value);
                        moneyAndQuantityThreshold(data.value);
                        lineOfCreditAndQuantityThreshold(data.value);
                        // addPermissionsGroupAddFn(false);
                    });

                    //授信方式操作
                    form.on('select(creditWay)', function (data) {
                        lineOfCreditAndQuantityThreshold(data.value);
                        // astrictMaterialFn(data.value);
                        // restrictWayFn(data.value);
                        // materialIdBox(data.value);
                        // addPermissionsGroupAddFn(false);
                        // isShowTable(data.value);
                    });

                    //是否限制物料操作
                    form.on('select(astrictMaterial)', function (data) {
                        restrictWayFn(data.value);
                        materialIdBox(data.value);
                        addPermissionsGroupAddFn(false);
                        isShowTable(data.value);
                    });

                    //限制方式操作
                    form.on('radio(materiel)', function (data) {
                        materialIdBox(data.value);
                        addPermissionsGroupAddFn(data.value);
                        isShowTable(data.value);
                    });


                    /*
                    * 授信方式渲染
                    * */
                    function creditType(_type) {
                        let selectMoneyData = [
                                {name: '组员共享领用金额', value: 'share'},
                                {name: '组员独立授信领用金额', value: 'independent'},
                                {name: '不限制领用金额', value: 'unlimited'},
                            ],
                            selectQuantityData = [
                                {name: '组员共享领用数量', value: 'shareQuantity'},
                                {name: '组员独立授信领用数量', value: 'independentQuantity'},
                                {name: '不限制领用数量', value: 'unlimitedQuantity'},
                            ];
                        if (_type == "money") {
                            loadSelectHtmlNew(selectMoneyData, '请选择授信方式', 'creditWay', '[lay-filter="addPermissionsGroupForm"]', 3)
                        } else if (_type == "quantity") {
                            loadSelectHtmlNew(selectQuantityData, '请选择授信方式', 'creditWay', '[lay-filter="addPermissionsGroupForm"]', 3)
                        }
                    }

                    // 未归还金额阈值 未归还数量阈值
                    function moneyAndQuantityThreshold(_type){
                        if (_type == "money") {
                            $('#moneyThresholdBox').css('display', 'block');
                            $('#moneyThresholdBox input[name="moneyThreshold"]').attr('lay-verify', 'number');

                            $('#quantityThresholdBox').css('display', 'none');
                            $('#quantityThresholdBox input[name="quantityThreshold"]').removeAttr('lay-verify');
                            $('#quantityThresholdBox input[name="quantityThreshold"]').val('');

                        } else if (_type == "quantity") {
                            $('#quantityThresholdBox').css('display', 'block');
                            $('#quantityThresholdBox input[name="quantityThreshold"]').attr('lay-verify', 'number');

                            $('#moneyThresholdBox').css('display', 'none');
                            $('#moneyThresholdBox input[name="moneyThreshold"]').removeAttr('lay-verify');
                            $('#moneyThresholdBox input[name="moneyThreshold"]').val('');
                        }
                    }

                    // 物料金额限制阈值 物料数量限制阈值
                    function lineOfCreditAndQuantityThreshold(_type){
                        if (_type == "money") {
                            $('#lineOfCreditBox').css('display', 'block');
                            $('#lineOfCredit').attr('lay-verify', 'number');
                            $('#authorizedQuantityBox').css('display', 'none');
                            $('#authorizedQuantity').removeAttr('lay-verify');
                            $('#authorizedQuantity').val('');
                        } else if (_type == "quantity") {
                            $('#authorizedQuantityBox').css('display', 'block');
                            $('#authorizedQuantity').attr('lay-verify', 'number');
                            $('#lineOfCreditBox').css('display', 'none');
                            $('#lineOfCredit').removeAttr('lay-verify');
                            $('#lineOfCredit').val('');
                        }else if(_type == "unlimited"){
                            $('#lineOfCreditBox').css('display', 'none');
                            $('#lineOfCredit').removeAttr('lay-verify');
                            $('#lineOfCredit').val('');
                        }else if(_type == "unlimitedQuantity"){
                            $('#authorizedQuantityBox').css('display', 'none');
                            $('#authorizedQuantity').removeAttr('lay-verify');
                            $('#authorizedQuantity').val('');
                        }else {
                            if ($('input[name="creditType"]:checked').val() == 'money') {
                                $('#lineOfCreditBox').css('display', 'block');
                                $('#lineOfCredit').attr('lay-verify', 'number');
                            }else if($('input[name="creditType"]:checked').val() == 'quantity'){
                                $('#authorizedQuantityBox').css('display', 'block');
                                $('#authorizedQuantity').attr('lay-verify', 'number');
                            }
                        }
                    }

                    // 是否限制物料（显示不显示）
                    function astrictMaterialFn(_type){
                        if (_type === 'unlimited' || _type === 'unlimitedQuantity'){
                            $('#astrictMaterialBox').hide()
                        }else {
                            $('#astrictMaterialBox').show();
                        }
                    }

                    // 限制方式（显示不显示）
                    function restrictWayFn(_type){
                        if (_type === 'unlimited' || _type === 'unlimitedQuantity'){
                            $('#restrictWayBox').hide();
                            $('#restrictWayBox  input[name="restrictWay"]').removeAttr('checked');
                        }else if(_type === 'noAstrict'){
                            $('#restrictWayBox').hide();
                            $('#restrictWayBox  input[name="restrictWay"]').removeAttr('checked');
                        }else {
                            $('#restrictWayBox').show();
                            $('#restrictWayBox  input[name="restrictWay"]').eq(0).prop('checked', 'true');
                        }
                        form.render('radio');
                    }

                    let smlSelectInstansExt = xmSelect.render({
                        el: '#materialId',
                        model: {label: {type: 'text'}},
                        clickClose: true,
                        filterable: true,
                        layVerify: 'required',
                        disabled: data ? _type == 'details' ? true : false : false,
                        tree: {
                            show: true,
                            strict: false,
                            expandedKeys: [-1],
                        },
                        tips: '顶级分类',
                        prop: {
                            name: 'name',
                            value: 'id',
                            children: 'children'
                        },
                        data() {
                            //填充数据
                            return arr2treeExt;
                        },
                        on: function (data) {
                            let id = '';
                            for (var j = 0; j < data.arr.length; j++) {
                                if (j == 0) {
                                    id = data.arr[j].id
                                } else {
                                    id += ',' + data.arr[j].id;
                                }
                            }
                            $("input[name='materialId']").val(id);

                            layer.load(2);
                            admin.req('enterprisecab/cabinet/admin/authorityManage/findMateriel',{page: 1, limit: 99999,categoryIds:id},res=>{
                                layer.closeAll('loading');
                                if (res.code == 200){
                                    res.data.forEach(item=>{
                                        item.manageld = '';
                                        item.id = void 0;
                                        if($('input[name="authorizedQuantity"]').val()>0){
                                            item.number = $('input[name="authorizedQuantity"]').val();
                                        }else if($('input[name="lineOfCredit"]').val()){
                                            item.amount = $('input[name="lineOfCredit"]').val();
                                        }else {
                                            item.number = '';
                                            item.amount = '';
                                        }
                                        item.colsIsShow = false;
                                    });

                                    addPermissionsGroupFormTbData = res.data;
                                    table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                                }
                            })
                        }
                    });
                    //可领物资分类（显示不显示）
                    function materialIdBox(_type){
                        if(_type === 'unlimited' || _type === 'unlimitedQuantity'){
                            $('#materialIdBox').hide();
                            $('#materialIdBox input').val('');
                            smlSelectInstansExt.setValue([]);
                            smlSelectInstansExt.update({layVerify:''});
                        }else if(_type === 'noAstrict'){
                            $('#materialIdBox').hide();
                            $('#materialIdBox input').val('');
                            smlSelectInstansExt.setValue([]);
                            smlSelectInstansExt.update({layVerify:''});
                        }else if(_type ==='materiel'){
                            $('#materialIdBox').hide();
                            $('#materialIdBox input').val('');
                            smlSelectInstansExt.setValue([]);
                            smlSelectInstansExt.update({layVerify:''});
                        }else {
                            $('#materialIdBox').show();
                            smlSelectInstansExt.update({layVerify:'required'})
                        }
                    }

                    // 添加限制物料按钮（显示不显示）
                    function addPermissionsGroupAddFn(_type){
                        if (_type === 'unlimited' || _type === 'unlimitedQuantity'){
                            $('#addPermissionsGroupAdd').hide();
                        }else if(_type === 'noAstrict'){
                            $('#addPermissionsGroupAdd').hide();
                        }else if(_type ==='category'){
                            $('#addPermissionsGroupAdd').hide();
                        }else if(_type === false){
                            $('#addPermissionsGroupAdd').hide();
                        }else{
                            $('#addPermissionsGroupAdd').show();
                        }
                    }

                    //添加限制物料
                     function addPermissionsGroupAddPup(){
                         if (addPermissionsGroupFormTbData.length>0){
                             ids ='';
                             addPermissionsGroupFormTbData.forEach((item,index)=>{
                                 if ((index+1) === addPermissionsGroupFormTbData.length){
                                     ids += item.skuCode;
                                 }else {
                                     ids += item.skuCode+",";
                                 }
                             })
                         }

                         let addRestrictedMaterialsPopUp = admin.open({
                             type: 1,
                             area: ['1200px', '820px'],
                             offset: '65px',
                             title: '添加限制物料',
                             content: $('#addRestrictedMaterialsTemplate').html(),
                             success: function (_data) {
                                 let addRestrictedMaterialsFormTb = table.render({
                                     elem: '#addRestrictedMaterialsFormTable',
                                     url: config.base + 'enterprisecab/cabinet/admin/authorityManage/findMateriel',
                                     page: true,
                                     where: {ids,categoryIds},
                                     limit: 5,
                                     limits: [5, 10, 20, 30, 40, 50, 60, 70, 80],
                                     cellMinWidth: 100,
                                     cols: [[
                                         {type: 'checkbox'}
                                         , {
                                             field: 'productPic',
                                             title: '图片',
                                             templet: d => d.productPic ? '<img src="' + d.productPic + '" style="cursor: pointer"/>' : '<img src="assets/images/default-icon.png"/>'
                                         }
                                         , {field: 'skuName', title: '物料名称'}
                                         , {field: 'skuCode', title: '物料编号'}
                                         , {field: 'oldSpecCode', title: '物料规格'}
                                         , {field: 'packName', title: '包装规格'}
                                         , {field: 'productBrandName', title: '所属品牌'}
                                         , {field: 'unitName', title: '单位'}
                                     ]],
                                 });


                                 $('#addRestrictedMaterialsFormSubmit').click(function () {
                                     let checkStatus = table.checkStatus('addRestrictedMaterialsFormTable');
                                     if (checkStatus.data.length === 0) {
                                         layer.msg('请选择需要导出的数据', {icon: 5});
                                         return false;
                                     }
                                     checkStatus.data.forEach(item=>{
                                         item.manageld = '';
                                         item.id = void 0;
                                         if($('input[name="authorizedQuantity"]').val()>0){
                                             item.number = $('input[name="authorizedQuantity"]').val();
                                         }else if($('input[name="lineOfCredit"]').val()){
                                             item.amount = $('input[name="lineOfCredit"]').val();
                                         }else {
                                             item.number = '';
                                             item.amount = ''
                                         }
                                         item.colsIsShow = true;
                                     });

                                     addPermissionsGroupFormTbData = [...addPermissionsGroupFormTbData , ...checkStatus.data];

                                     table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                                     layer.close(addRestrictedMaterialsPopUp);
                                 });

                                 // 搜索
                                 form.on('submit(addRestrictedMaterialsFormSearch)', function (data) {
                                     addRestrictedMaterialsFormTb.reload({where: data.field,page: {curr: 1}},'data');
                                 });

                             }


                         });
                    }

                    function isShowTable(_type){
                        if(_type === 'unlimited' || _type === 'unlimitedQuantity'){
                            addPermissionsGroupFormTbData = [];
                            table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                        }else if(_type === 'noAstrict'){
                            addPermissionsGroupFormTbData = [];
                            table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                        }else if(_type === 'materiel' || _type === 'category'){
                            addPermissionsGroupFormTbData = [];
                            table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                        }

                    }
                    if(data){
                        data.status = data.status == 0 ? 'on' : '';
                        creditType(data.creditType);
                        moneyAndQuantityThreshold(data.creditType);
                        lineOfCreditAndQuantityThreshold(data.creditType);
                        restrictWayFn(data.astrictMaterial);

                        if(data.astrictMaterial === 'astrict'){
                            addPermissionsGroupAddFn(data.restrictWay);
                            materialIdBox(data.restrictWay);
                        }else {
                            addPermissionsGroupAddFn(false);
                            materialIdBox(data.astrictMaterial)
                        }
                        if(data.creditWay =='unlimitedQuantity' || data.creditWay === 'unlimited'){
                            // addPermissionsGroupAddFn(data.creditWay);
                            // addPermissionsGroupAddFn(data.astrictMaterial);
                            // materialIdBox(data.creditWay);
                            // materialIdBox(data.astrictMaterial);


                            // restrictWayFn(data.creditWay)
                        }else {
                            // addPermissionsGroupAddFn(data.restrictWay);
                            // addPermissionsGroupAddFn(data.astrictMaterial);
                            // materialIdBox(data.restrictWay);
                            // materialIdBox(data.astrictMaterial);

                        }

                        if (_type == 'details') {
                            $('[lay-filter="addPermissionsGroupForm"] input').attr('disabled', 'disabled');
                            $('[lay-filter="addPermissionsGroupForm"] select').attr('disabled', 'disabled');
                            $('[lay-filter="addPermissionsGroupForm"] input').css('borderColor', 'transparent');
                            $('button[lay-filter="addPermissionsGroupFormSubmit"]').remove();
                            $('#addPermissionsGroupAdd').remove();
                        } else {
                            $('form[lay-filter="addPermissionsGroupForm"]  input[name="name"]').attr('disabled', 'disabled');

                            //添加限制物料
                            $('#addPermissionsGroupAdd').click(function () {
                                addPermissionsGroupAddPup();
                            });

                            form.on('submit(addPermissionsGroupFormSubmit)', function (d) {
                                let authorityMaterielList = [];
                                addPermissionsGroupFormTbData.forEach(item=>{
                                    let obj = {};
                                    obj.skuCode = item.skuCode;
                                    obj.id = item.id;
                                    // obj.categoryld = item.id;
                                    obj.categoryId = item.productCategoryId;

                                    if (item.manageId){
                                        obj.manageld = item.manageId;
                                    }else {
                                        obj.manageld = '';
                                    }
                                    if(d.field.lineOfCredit && d.field.lineOfCredit > 0){
                                        obj.amount = item.amount;
                                    }else {
                                        obj.number = item.number
                                    }
                                    authorityMaterielList.push(obj)
                                });
                                layer.load(2);
                                d.field.cabinetId = cabinetData.id;
                                d.field.cabinetCode = cabinetData.cabCode;
                                d.field.status = d.field.status == 'on' ? 0 : 1;
                                d.field.authorityMaterielList = authorityMaterielList;

                                admin.req('enterprisecab/cabinet/admin/authorityManage/update', JSON.stringify(d.field), function (res) {
                                    layer.closeAll('loading');
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {icon: 1});
                                        table.reload('mainCabinetAuthorityTable');
                                        layer.close(addPermissionsGroupPopUp);
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'PUT', true, 'application/json; charset=utf-8');
                                return false
                            });
                        }

                        form.val('addPermissionsGroupForm', data);
                        selectedDataExt(arr2treeExt, data.materialId);
                        smlSelectInstansExt.setValue(data.materialId.split(","));


                        authorityManageId = data.id;

                        admin.req('enterprisecab/cabinet/admin/authorityManage/findMateriel',{ids,categoryIds,authorityManageId},res=>{
                            if(res.code === 200){
                                res.data.forEach(item=>{
                                    if(data.restrictWay == 'materiel' && _type == 'modify'){
                                        item.colsIsShow = true;
                                    }
                                    addPermissionsGroupFormTbData.push(item)

                                });

                                table.reload('addPermissionsGroupFormTable', {data: addPermissionsGroupFormTbData});
                            }
                        });



                    }else {

                        //添加限制物料
                        $('#addPermissionsGroupAdd').click(function () {
                            addPermissionsGroupAddPup();
                        });
                        form.on('submit(addPermissionsGroupFormSubmit)', function (d) {
                            let authorityMaterielList = [];
                            addPermissionsGroupFormTbData.forEach(item=>{
                                let obj = {};
                                obj.skuCode = item.skuCode;
                                // obj.categoryld = item.id;
                                obj.categoryId = item.productCategoryId;

                                obj.manageld = '';
                                if(d.field.lineOfCredit){
                                    obj.amount = item.amount;
                                }else {
                                    obj.number = item.number
                                }
                                authorityMaterielList.push(obj)
                            });
                            layer.load(2);
                            d.field.cabinetId = cabinetData.id;
                            d.field.cabinetCode = cabinetData.cabCode;
                            d.field.status = d.field.status == 'on' ? 0 : 1;
                            d.field.authorityMaterielList = authorityMaterielList;

                            admin.req('enterprisecab/cabinet/admin/authorityManage/add', JSON.stringify(d.field), function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('mainCabinetAuthorityTable');
                                    layer.close(addPermissionsGroupPopUp);
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'POST', true, 'application/json; charset=utf-8');
                            return false
                        });
                    }
                    form.render();
                }
            })
        }

        /*权限 --》成员管理*/
        function showMemberForm(data) {
            admin.open({
                type: 1,
                area: ['1400px', '700px'],
                offset: '75px',
                title: '设备权限组成员管理',
                content: $('#memberForm').html(),
                success: function (_data) {
                    let permissionsData = data;
                    let memberFormTB = table.render({
                        elem: '#memberFormTable',
                        url: config.base + 'enterprisecab/cabinet/admin/authorityMember/list?authorityManageId=' + data.id,
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'checkbox'}
                            , {field: 'userName', title: '成员姓名'}
                            , {field: 'jobNumber', title: '工号'}
                            , {field: 'phone', title: '电话'}
                            , {field: 'enterpriseName', title: '所属公司'}
                            , {field: 'deptName', title: '所属部门'}
                            , {field: 'positionName', title: '所属岗位'}
                            , {field: '', title: '所属权限组(以主柜面板为单位)', templet: d => data.name}
                            , {field: 'isDeleted', title: '状态', templet: d => d.isDeleted ? '正常' : '禁用'}
                            , {field: 'createTime', title: '创建时间'}
                            , {field: 'creatorName', title: '添加人'}
                            , {toolbar: '#memberFormTableBar', title: '操作'}
                        ]],
                    });

                    // 工具条点击事件
                    table.on('tool(memberFormTable)', function (obj) {
                        let data = obj.data;
                        if (obj.event === 'details') { //详情
                            showAddPermissionGroupMembersForm('details', Object.assign(permissionsData, data));
                        } else if (obj.event === 'delete') {  //删除
                            layer.confirm('确定要删除吗？', {
                                offset: '65px',
                                skin: 'layui-layer-admin'
                            }, function (i) {
                                layer.close(i);
                                layer.load(2);
                                admin.req('enterprisecab/cabinet/admin/authorityMember/' + data.id, {}, res => {
                                    layer.closeAll('loading');
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {icon: 1});
                                        table.reload('memberFormTable');
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'DELETE')
                            });
                        }
                    });


                    $('#memberFormBatchDeletion').click(function () { // 批量操作
                        let checkRows = table.checkStatus('memberFormTable');
                        if (checkRows.data.length == 0) {
                            layer.msg('请选择要删除的数据', {icon: 2});
                        } else {
                            new Promise((resolve, reject) => {
                                let ids = '';
                                checkRows.data.forEach(item => {
                                    ids += item.id + ','
                                });
                                resolve(ids.substr(0, ids.length - 1));
                            }).then(rData => {
                                layer.load(2);
                                admin.req('enterprisecab/cabinet/admin/authorityMember/batchIds', {ids: rData.split(',')}, res => {
                                    layer.closeAll('loading');
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {icon: 1});
                                        table.reload('memberFormTable');
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'DELETE')
                            });
                        }
                    });
                    $('#addMembersBtn').click(function () { // 添加权限组成员
                        showAddPermissionGroupMembersForm('add', data)
                    });

                    $('#memberFormExport').click(function () {  //导出
                        let checkRows = table.checkStatus('memberFormTable');
                        if (checkRows.data.length == 0) {
                            layer.msg('请选择要导出的数据', {icon: 2});
                        } else {
                            table.exportFile(memberFormTB.config.id, checkRows.data, 'xls');
                        }
                    })

                    //搜索
                    form.on('submit(memberFormSearch)', function (data) {
                        memberFormTB.reload({where: data.field, page: {curr: 1}}, 'data');
                    });

                }
            })
        }

        //  添加权限组成员
        function showAddPermissionGroupMembersForm(_type, data) {
            let addPermissionGroupMembersPopUp = admin.open({
                type: 1,
                area: ['1200px', '750px'],
                offset: '85px',
                title: _type === 'details' ? '权限组成员详情' : '添加权限组成员',
                content: $('#addPermissionGroupMembers').html(),
                success: function (_data) {

                    $('#addPermissionGroupMembersFormAuthorizedQuantityBox').hide();
                    $('#addPermissionGroupMembersFormAuthorizedQuantityBox>input[name="authorizedQuantity"]').val('');
                    $('#addPermissionGroupMembersFormLineOfCreditBox').hide();
                    $('#addPermissionGroupMembersFormLineOfCreditBox>input[name="authorizedQuantity"]').val('');

                    if (data.creditType == "money") {
                        if (data.creditWay == 'unlimited') {
                            $('#addPermissionGroupMembersFormLineOfCreditBox').hide()
                        } else {
                            $('#addPermissionGroupMembersFormLineOfCreditBox').show()
                        }
                    } else if (data.creditType == "quantity") {
                        if (data.creditWay == 'unlimitedQuantity') {
                            $('#addPermissionGroupMembersFormAuthorizedQuantityBox').hide()
                        } else {
                            $('#addPermissionGroupMembersFormAuthorizedQuantityBox').show()
                        }
                    }

                    if (data.astrictMaterial == 'noAstrict') {
                        $('#materialId1Box').hide()
                    } else {
                        $('#materialId1Box').show()
                    }


                    let enterpriseName = '', deptName = '', positionName = '', userName = '';

                    let arr2treeExt;
                    let selectedData = function (treeData, targetId) {
                        for (var k = 0; k < treeData.length; k++) {
                            var nodeId = treeData[k].id;
                            if (targetId == nodeId) {
                                treeData[k].selected = true;
                                return;
                            } else {
                                if (treeData[k].children && treeData[k].children != '') {
                                    selectedData(treeData[k].children, targetId);
                                }
                            }
                        }
                    };
                    // enterprise/product/admin/productCategory/list?limit=9999&enterprise=0&page=1
                    admin.req('enterprise/knife/admin/productCategoryKnife/list?limit=9999&enterprise=0&page=1', {}, function (res) {
                        for (let i = 0; i < res.data.length; i++) {
                            res.data[i].children = [];
                        }
                        arr2treeExt = xmSelect.arr2tree(res.data, "parentId", "id", "children", -1);
                    }, 'get', false);

                    let selectedDataExt = function (treeData, targetId) {
                        var ids = targetId.split(",");
                        for (var k = 0; k < treeData.length; k++) {
                            var nodeId = treeData[k].id;
                            for (var t = 0; t < ids.length; t++) {
                                if (ids[t] == nodeId) {
                                    treeData[k].selected = true;
                                    continue;
                                } else {
                                    if (treeData[k].children && treeData[k].children != '') {
                                        selectedData(treeData[k].children, ids[t]);
                                    }
                                }
                            }
                        }
                    };

                    if (_type === 'details') {
                        form.val('addPermissionGroupMembersForm', data);
                        selectedDataExt(arr2treeExt, data.materialId);
                        $('.addPermissionGroupMembersDetail').show();
                        $('#userIdBox').hide();
                        $('[lay-filter="addPermissionGroupMembersForm"] input').attr('disabled', 'disabled');
                        // $('[lay-filter="addPermissionGroupMembersForm"] select').attr('disabled', 'disabled');
                        $('[lay-filter="addPermissionGroupMembersForm"] input').css('borderColor', 'transparent');
                        $('[lay-filter="addPermissionGroupMembersForm"] input').css('', 'transparent');
                        $('button[lay-filter="addPermissionGroupMembersFormSubmit"]').hide();
                        // loadSelectHtmlNew('', data.deptName, 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                        // loadSelectHtmlNew('', data.enterpriseName, 'enterpriseId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                        // loadSelectHtmlNew('', data.positionName, 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                        // loadSelectHtmlNew('', data.userName, 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 1)

                    } else {
                        data.remark = '';
                        data.jobNumber = '';
                        data.phone = '';
                        data.isDeleted = true;
                        form.val('addPermissionGroupMembersForm', data);
                        selectedDataExt(arr2treeExt, data.materialId);
                        /*admin.req('user/admin/companyInfo/list?limit=9999', {}, res => {
                            if (res.code == '200') {
                                loadSelectHtmlNew(res.data, '请选择企业', 'enterpriseId', '[lay-filter="addPermissionGroupMembersForm"]', 1)
                            }
                        }, 'GET');*/

                       /* form.on('select(enterpriseId)', function (data) {
                            if (data.value != '') {
                                admin.req('user/admin/department/list?limit=9999&companyInfoId=' + data.value, {}, res => {
                                    enterpriseName = data.elem[data.elem.selectedIndex].text;
                                    if (res.code == '200') {
                                        loadSelectHtmlNew(res.data, '请选择选择部门', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew('', '请选择岗位', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                        loadSelectHtmlNew('', '请选择选择部门', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew('', '请选择岗位', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                                    }
                                }, 'GET');
                            } else {
                                loadSelectHtmlNew('', '请选择选择部门', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew('', '请选择岗位', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                            }

                        });

                        form.on('select(deptId)', function (data) {
                            deptName = data.elem[data.elem.selectedIndex].text;
                            if (data.value != '') {
                                admin.req('user/admin/role/list?limit=9999&departmentId=' + data.value, {}, res => {
                                    if (res.code == '200') {
                                        loadSelectHtmlNew(res.data, '请选择岗位', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'GET');
                            } else {
                                loadSelectHtmlNew('', '请选择岗位', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                            }
                        });

                        form.on('select(positionId)', function (data) {
                            positionName = data.elem[data.elem.selectedIndex].text;
                            if (data.value != '') {
                                admin.req('user/admin/user/getUserByPostId?limit=9999&postId=' + data.value, {}, res => {
                                    if (res.code == '200') {
                                        loadSelectHtmlNew(res.data, '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                    }
                                }, 'GET');
                            } else {
                                loadSelectHtmlNew('', '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 2);
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('')
                            }
                        });*/

                        /*form.on('select(userId)', function (data) {
                            userName = data.elem[data.elem.selectedIndex].text;
                            if (data.value != '') {
                                admin.req('enterprisecab/cabinet/admin/authorityMember/getAuthorityMemberByUserId', {id: data.value,'cabinetId':cabinetId}, res => {
                                    if (res.code == '200') {
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val(res.data.data.phone);
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val(res.data.data.username)
                                    } else {
                                        layer.msg(res.msg, {icon: 2});
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('');
                                        $('form[lay-filter="addPermissionGroupMembersForm"] select[name="userId"]').val('');

                                        loadSelectHtmlNew([], '', 'enterpriseId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew([], '', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        loadSelectHtmlNew([], '', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                        form.render();
                                    }
                                }, 'GET');

                                let bringData = JSON.parse($(data.elem).find("option:selected").attr("data"));
                                let enterpriseData = [{id:bringData.companyInfoId,name:'暂无企业'}],
                                    deptData = [{id:bringData.departmentId,name:'暂无部门'}],
                                    positionData = [{id:'',name:'暂无岗位'}];

                                if(bringData.companyInfoName){
                                    enterpriseData = [{id:bringData.companyInfoId,name:bringData.companyInfoName}];
                                }
                                if(bringData.departmentName){
                                    deptData = [{id:bringData.departmentId,name:bringData.departmentName}]
                                }
                                if(bringData.roles.length > 0){
                                    positionData = [{id:bringData.roles[0].id,name:bringData.roles[0].name}] ;
                                }

                                loadSelectHtmlNew(enterpriseData, '', 'enterpriseId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew(deptData, '', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew(positionData, '', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);

                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val(bringData.phone);
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val(bringData.username);

                                positionName = bringData.roles[0].name;
                                deptName = bringData.departmentName;
                                enterpriseName = bringData.companyInfoName;

                            } else {
                                loadSelectHtmlNew([], '', 'enterpriseId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew([], '', 'deptId', '[lay-filter="addPermissionGroupMembersForm"]', 1);
                                loadSelectHtmlNew([], '', 'positionId', '[lay-filter="addPermissionGroupMembersForm"]', 1);

                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="phone"]').val('');
                                $('form[lay-filter="addPermissionGroupMembersForm"] input[name="jobNumber"]').val('');

                                positionName = '';
                                deptName = '';
                                enterpriseName = ''
                            }

                        });*/

                        // 提交
                        let formDataList = new Map();
                        form.on('submit(addPermissionGroupMembersFormSubmit)', function (d) {
                            layer.load(2);
                            let pushDataList = [];
                            formDataList.forEach((value, key)=>{
                                let obj = {
                                    name: d.field.name,
                                    lineOfCredit: d.field.lineOfCredit,
                                    authorizedQuantity: d.field.authorizedQuantity,
                                    materialId:d.field.materialId,
                                    userId: value.id,
                                    enterpriseId:value.companyInfoId,
                                    deptId: value.departmentId,
                                    positionId:value.roles.length>0?value.roles[0].id:'',
                                    jobNumber:value.username,
                                    phone:value.phone,
                                    isDeleted: d.field.isDeleted=='on'?true:false,
                                    remark: d.field.remark,
                                    authorityManageId: data.id,
                                    userName : value.nickname,
                                    positionName : value.roles.length>0?value.roles[0].name:'',
                                    deptName : value.departmentName,
                                    enterpriseName : value.companyInfoName
                                }
                                pushDataList.push(obj)
                            });

                          admin.req('enterprisecab/cabinet/admin/authorityMember/addBatch', JSON.stringify(pushDataList), function (res) {
                             layer.closeAll('loading');
                             if (res.code == 200) {
                                 layer.msg(res.msg, {icon: 1});
                                 table.reload('memberFormTable');
                                 layer.close(addPermissionGroupMembersPopUp);
                                 table.reload('mainCabinetAuthorityTable');
                             } else {
                                 layer.msg(res.msg, {icon: 2});
                             }
                         }, 'POST' , true, 'application/json; charset=utf-8');
                            return false
                        });


                        let userIdBox = xmSelect.render({
                            el: '#userIdBox',
                            filterable: true,
                            autoRow: true,
                            layVerify: 'required',
                            template({ item, sels, name, value }){
                                let roles = item.roles[0]?item.roles[0].name:"";
                                return  "<span class='colorBlack'>" + item.nickname + "</span><span style='font-weight: 600'>工号:</span>" +
                                    "<span class='colorBlack1'>" + item.username + "</span><span style='font-weight: 600'>电话:</span>" +
                                    "<span class='colorBlack1'>" + item.phone + "</span><span style='font-weight: 600'>岗位:</span>" +
                                    "<span class='colorBlack1'>" + roles+ "</span><span style='font-weight: 600'>部门:</span>" +
                                    "<span class='colorBlack1'>" + item.departmentName + "</span><span style='font-weight: 600'>企业:</span>" +
                                    "<span class='colorBlack1'>" + item.companyInfoName + "</span>";
                            },
                            filterMethod: function(val, item, index, prop){
                                let roles = item.roles[0]?item.roles[0].name:"";
                                if(roles.toLowerCase().indexOf(val.toLowerCase()) != -1){//把value相同的搜索出来
                                    return true;
                                }
                                if(item.username.toLowerCase().indexOf(val.toLowerCase()) != -1){//把value相同的搜索出来
                                    return true;
                                }

                                if(item.nickname.toLowerCase().indexOf(val.toLowerCase()) != -1){//名称中包含的搜索出来
                                    return true;
                                }
                                return false;//不知道的就不管了
                            },
                            prop: {
                                name: 'nickname',
                                value: 'id',
                            },
                            data: [],
                            on: function(data){
                                if (data.isAdd){
                                    admin.req('enterprisecab/cabinet/admin/authorityMember/getAuthorityMemberByUserId', {id: data.change[0].id,'cabinetId':cabinetId}, res => {
                                        if (res.code === 200){
                                            formDataList.set(data.change[0].id,data.change[0])
                                            $('input[name="enterpriseId"]')
                                        }else {
                                            let index = data.arr.findIndex(item => item.id === data.change[0].id);
                                            if(index != -1){data.arr.splice(index, 1);}
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    })
                                }else {
                                    formDataList.delete(data.change[0].id)
                                }
                            }
                        });

                        admin.req('user/admin/user/list',{limit : '99999'},res=>{
                            if (res.code === 200){
                                // loadSelectHtmlNew(res.data, '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 7);
                                userIdBox.update({data: res.data});
                            }else {
                                // loadSelectHtmlNew([], '请选择人员', 'userId', '[lay-filter="addPermissionGroupMembersForm"]', 7);
                                userIdBox.update({data: [],})
                            }
                        })

                    }
                    let smlSelectInstansExt = xmSelect.render({
                        el: '#materialId1',
                        model: {label: {type: 'text'}},
                        clickClose: true,
                        filterable: true,
                        disabled: true,
                        tree: {
                            show: true,
                            strict: false,
                            expandedKeys: [-1],
                        },
                        tips: '顶级分类',
                        prop: {
                            name: 'name',
                            value: 'id',
                            children: 'children'
                        },
                        data() {
                            //填充数据
                            return arr2treeExt;
                        },
                        on: function (data) {
                            let id = '';
                            for (var j = 0; j < data.arr.length; j++) {
                                if (j == 0) {
                                    id = data.arr[j].id
                                } else {
                                    id += ',' + data.arr[j].id;
                                }
                            }
                            $("form[lay-filter='addPermissionGroupMembersForm'] input[name='materialId']").val(id)
                        }
                    });


                    form.render("select");
                    form.render("checkbox");
                }
            })
        }


        /*主柜货道点击事件*/
        $('#mainBoxList').delegate('.cargo', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            cargoPop(data)
        });

        /*副柜货道点击事件*/
        $('#auxiliaryBoxList').delegate('.cargo', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            cargoPop(data)
        });

        /*货道弹窗*/
        function cargoPop(data) {
            admin.open({
                type: 1,
                area: ['1280px', '650px'],
                offset: '65px',
                title: '货道',
                content: $('#mainCabinetCargoForm').html(),
                success: function () {
                    let limit = 6, page = 1;
                    let cabType = data.cabinetNature, queryFlag = undefined;
                    let url = 'enterprisecab/cabinet/admin/cabinetCargoLane/list?cabinetId=' + data.id + '&sort=id';
                    if (cabType == 'main') {
                        queryFlag = "mainCab";
                        url = 'enterprisecab/cabinet/admin/cabinetCargoLane/list?mainCabCode=' + data.cabCode + '&sort=id&queryFlag=' + queryFlag + '&cabinetNature=sale';
                    }
                    //搜索
                    form.on('submit(mainCabinetCargoSearch)', function (data) {
                        page = 1;
                        getMainCabinetCargoData(data.field);
                        return false;
                    });
                    // 重置搜索
                    form.on('submit(resets)', function (data) {
                        $(".mainCabinetCargoFormHeader").find('select').val("");
                        $(".mainCabinetCargoFormHeader").find('input').val("");
                        let field = data.field;
                        for (let key in field) {
                            field[key] = ''
                        }
                        page = 1;
                        getMainCabinetCargoData();
                        return false;
                    });


                    getMainCabinetCargoData();

                    // 请求货道数据
                    function getMainCabinetCargoData(_data) {
                        let obj = Object.assign({}, {limit, page}, _data);
                        layer.load(2);
                        admin.req(url, obj, res => {
                            layer.closeAll('loading');
                            if (res.code === 200) {
                                showMainCabinetCargoHtml(res.data);
                                laypage.render({
                                    elem: 'cargoPage', count: res.count, limit, curr: page
                                    , jump: function (obj, first) {
                                        if (!first) {
                                            page = obj.curr;
                                            getMainCabinetCargoData();
                                        }
                                    }
                                });
                            } else {
                                showMainCabinetCargoHtml([]);
                            }
                        })
                    }

                    // 渲染货道页面
                    function showMainCabinetCargoHtml(_data) {

                        if (!_data || _data.length === 0) {
                            $('#cargoBox').html('<h3 class="noData">暂无内容~~~</h3>');
                            return false;
                        }

                        let html = '';
                        _data.forEach((item, index) => {
                            html += `  <div class="cargoBoxItem">
                                        <div class="cargoBoxItemContent">
                                            <div class="cargoBoxItemImage">
                                                <div class="cargoBoxItemImageTitle">货道编号:${item.code}</div>
                                                <img src="${item.skuPic ? item.skuPic : 'assets/images/cabinet/noCargo.png'}">
                                            </div>
                                            <div class="cargoBoxItemInfo">
                                                <div class="cargoBoxItemInfoTitle" title="${item.skuName}">物料名称:${item.skuName}</div>
                                                <div class="cargoBoxItemInfo1" title="${item.skuCode}">物料编码:${item.skuCode}</div>
                                                <div class="cargoBoxItemInfo1" title="${item.brandName}">品牌:${item.brandName}</div>
                                                <div class="cargoBoxItemInfo1" title="${item.currentStockCount}">库存数量：${item.currentStockCount}</div>
                                                <div class="cargoBoxItemInfo1" title="${item.quantity}">货道容量:${item.quantity}</div>
                                            </div>
                                        </div>
                                        <div class="cargoBoxItemInfoEdit" parentId="${item.id}" quantity="${item.quantity}" remark="${item.remark}">
                                            <i class="layui-icon layui-icon-edit"></i>修改参数
                                        </div>
                                    </div>`
                        });
                        $('#cargoBox').html(html);
                    }

                    $('#cargoBox').delegate('.cargoBoxItemInfoEdit', 'click', function (e) {
                        let obj = {
                            id: $(this).attr('parentId'),
                            quantity: $(this).attr('quantity'),
                            remark: $(this).attr('remark'),
                        };
                        // 货道编辑
                        let cargoLanelModifyFormOpen = admin.open({
                            type: 1,
                            area: "500px",
                            offset: '85px',
                            title: '编辑货道参数',
                            content: $('#cargoLanelModifyForm').html(),
                            success: function () {
                                form.val('cargoLanelModifyForm', obj);
                                //提交
                                form.on('submit(cargoLanelModifyFormSubmit)', (d) => {
                                    layer.load(2);
                                    let scatterFromSubmitData = Object.assign(obj, d.field);
                                    admin.req('enterprisecab/cabinet/admin/cabinetCargoLane/update', scatterFromSubmitData, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            layer.msg(res.msg, {icon: 1});
                                            getMainCabinetCargoData();
                                            layer.close(cargoLanelModifyFormOpen);
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }, 'PUT');
                                    return false;
                                })

                            }
                        })
                    });
                }
            });
        }

        /*主柜暂存柜点击事件*/
        $('#mainBoxList').delegate('.staging', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            stagingPop(data)
        });

        /*副柜暂存柜点击事件*/
        $('#auxiliaryBoxList').delegate('.staging', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            stagingPop(data)
        });

        /*暂存柜弹窗*/
        function stagingPop(data) {
            admin.open({
                type: 1,
                area: ['1280px', '810px'],
                offset: '65px',
                title: '暂存柜',
                content: $('#mainCabinetStagingForm').html(),
                success: function () {
                    form.render();
                    let limit = 10, page = 1;
                    let cabType = data.cabinetNature, queryFlag = undefined;
                    let url = 'enterprisecab/cabinet/admin/cabinetCargoSpace/list4pc?cabinetId=' + data.id + '&sort=id';
                    if (cabType == 'main') {
                        queryFlag = "mainCab";
                        url = 'enterprisecab/cabinet/admin/cabinetCargoSpace/list4pc?mainCabCode=' + data.cabCode + '&sort=id&queryFlag=' + queryFlag + '&cabinetNature=live';
                    }
                    if (data.cabinetNature == 'main') {
                        $('#mainCabinetStagingFormCabCodeBox').show();
                        admin.req('enterprisecab/cabinet/admin/cabinet/list', {
                            belongCabinet: data.cabCode,
                            cabinetNature: 'live'
                        }, res => {
                            if (res.code === 200) {
                                loadSelectHtmlNew(res.data, '请选择柜子编号', 'cabCode', '[lay-filter="mainCabinetStagingForm"]', 6)
                            } else {
                                loadSelectHtmlNew([], '请选择柜子编号', 'cabCode', '[lay-filter="mainCabinetStagingForm"]', 6)
                            }
                        })
                    } else {
                        $('#mainCabinetStagingFormCabCodeBox').hide();
                    }


                    //搜索
                    form.on('submit(mainCabinetStagingSearch)', function (data) {
                        page = 1;
                        getMainCabinetStagingData(data.field);
                        return false;
                    });

                    getMainCabinetStagingData();

                    // 请求暂存柜数据
                    function getMainCabinetStagingData(_data) {
                        let obj = Object.assign({}, {limit, page}, _data);
                        layer.load(2);
                        admin.req(url, obj, res => {
                            layer.closeAll('loading');
                            if (res.code === 200) {
                                showMainCabinetStagingHtml(res.data);
                                laypage.render({
                                    elem: 'stagingPage', count: res.count, limit, curr: page
                                    , jump: function (obj, first) {
                                        if (!first) {
                                            page = obj.curr;
                                            getMainCabinetStagingData(_data);
                                        }
                                    }
                                });
                            } else {
                                showMainCabinetStagingHtml([])
                            }
                        })
                    }

                    // 渲染暂存柜数据
                    function showMainCabinetStagingHtml(_data) {
                        if (!_data || _data.length === 0) {
                            $('#stagingBox').html('<h3 class="noData">暂无内容~~~</h3>');
                            return false;
                        }

                        let html = '';
                        _data.forEach((item, index) => {
                            html += `<div class="stagingBoxItem" data='${JSON.stringify(item)}'>
                                        <div class="stagingBoxItemHeader
                                                ${item.businessStatus == 'normal' ?
                                (item.spaceNature == 'personal' ? 'stagingBoxItemHeaderBg1' :
                                    (item.spaceNature == 'common' ? 'stagingBoxItemHeaderBg2' :
                                        (item.spaceNature == 'specialClass' ? 'stagingBoxItemHeaderBg2' : 'stagingBoxItemHeaderBg4'))) : ''}">
                                            ${item.spaceCode}
                                        </div>
                                        <div class="stagingBoxItemMain">
                                            <div class="stagingBoxItemTitle">性质：<span>${item.spaceNatureDesc}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">所属人员：<span>${item.principalName}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">物料类型：<span>${item.spaceProductTypeName}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">物料数：<span>${item.skuQuantity}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">货位容量：<span>${item.quantity}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">库存数量：<span>${item.quantityInventory}</span></div>
                                            <div class="stagingBoxItemInfo layui-elip">货位状态：<span>${item.businessStatusDesc}</span></div>
                                        </div>
                                        <div class="stagingBoxItemFooter">
                                            <div class="stagingBoxItemFooterEdit"><i class="layui-icon layui-icon-edit"></i>修改参数</div>
                                            <div class="stagingBoxItemFooterDetailed"><i class="layui-icon layui-icon-list"></i>库存明细</div>
                                        </div>
                                    </div> `
                        });
                        $('#stagingBox').html(html);

                    }

                    /* 主柜暂存柜明细点击事件*/
                    $('#stagingBox').delegate('.stagingBoxItemFooterDetailed', 'click', function (e) {
                        let obj = JSON.parse($(this).parents('.stagingBoxItem').attr('data'));
                        obj.cabType = data.cabinetNature;
                        obj.cabinetNature = data.cabinetNature;
                        obj.spaceCode = obj.code;
                        obj.cabinetId = data.id;
                        obj.cabCode = data.cabCode;
                        showMainCabinetStagingDetailed(obj);
                    });

                    /* 主柜暂存柜修改点击事件*/
                    $('#stagingBox').delegate('.stagingBoxItemFooterEdit', 'click', function (e) {
                        let obj = JSON.parse($(this).parents('.stagingBoxItem').attr('data'));
                        obj.cabType = data.cabinetNature;
                        obj.cabinetNature = data.cabinetNature;
                        obj.spaceCode = obj.code;
                        obj.cabinetId = data.id;
                        obj.cabCode = data.cabCode;
                        showSupplyParametersModifyForm(obj);
                    });

                    // 暂存柜货位属性设置修改弹窗
                    function showSupplyParametersModifyForm(data) {
                        data.skuCode = data.skuCodeTarget;
                        let supplyParametersModifyFormPopup = admin.open({
                            type: 1,
                            area: '800px',
                            offset: '100px',
                            title: '货位参数性质设置',
                            content: $('#supplyParametersModifyForm').html(),
                            success: function () {
                                console.log(data)
                                //权责人
                                admin.reqSync('user/admin/user/getAll', {}, res => {
                                    if (res.code == '200') {
                                        // loadSelectHtml(res.data, '请选择权责人', 'principal', 5)
                                        xmSelect.render({
                                            el: '#principal',
                                            filterable: true,
                                            initValue: data.principal.split(','),
                                            model: {label: {type: 'text'}},
                                            data() {
                                                let treeData = [];
                                                res.data.forEach(item => {
                                                    treeData.push({
                                                        name: item.nickname + "|" + item.username,
                                                        value: item.id
                                                    })
                                                });
                                                return treeData;
                                            },
                                            on: function (data) {
                                                let arr = data.arr, principalData = [], principalNameData = [];
                                                arr.forEach((item) => {
                                                    principalData.push(item.value);
                                                    principalNameData.push(item.name);
                                                });
                                                $('form[lay-filter="supplyParametersModifyForm"] input[name="principal"]').val(principalData.join());
                                                $('form[lay-filter="supplyParametersModifyForm"] input[name="principalName"]').val(principalNameData.join());
                                            },
                                        })
                                    }
                                }, 'GET');

                                var getProduct = function (productTypeId) {
                                    admin.req('enterprise/product/admin/productDetail/list', {
                                        productTypeId: productTypeId,
                                        limit: 999
                                    }, function (res) {

                                        if (res.code == 200) {
                                            let html = '<option value="">请选择物料</option>';
                                            for (var k = 0; k < res.data.length; k++) {
                                                html += '<option value="' + res.data[k].skuCode + '"data-skucode="' + res.data[k].skuCode + '">' + '物料编号:' + res.data[k].skuCode + '|物料名称:' + res.data[k].skuName + '|规格:' + res.data[k].oldSpecCode + '</option>'
                                            }
                                            $("#skuCode").html(html);
                                            form.render('select');
                                            if (data) {
                                                $("#skuCode").val(data.skuCode);
                                                form.render('select');
                                                // getCabSpace(data.cabId,data.skuCode);
                                            }
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }, 'GET');
                                };

                                //存储类目
                                admin.req('enterprise/product/admin/productType/getAllKnife', {limit: 999}, function (res) {
                                    if (res.code == '200') {
                                        // loadSelectHtml(res.data, '请选择存储类目', 'spaceProductType', 6)
                                        if (res.code == 200) {
                                            var html = '<option value="">请选择物料类型</option>'
                                            for (var k = 0; k < res.data.length; k++) {
                                                html += '<option value="' + res.data[k].id + '">' + res.data[k].name + '</option>'
                                            }
                                            $("#spaceProductType").html(html);
                                            form.render('select');
                                            if (data) {
                                                $("#spaceProductType").val(data.spaceProductType);
                                                form.render('select');
                                                getProduct(data.spaceProductType);
                                            }
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }
                                }, 'GET');


                                form.on('select(spaceProductType)', function (data) {
                                    if (data.value != '') {
                                        getProduct(data.value);
                                    }
                                })


                                /**
                                 if (data.spaceNature) {
                        if (data.spaceNature == "personal") { //专人存储
                            $('#principalBox').show();
                            //$('#spaceProductType').val('');
                            $('#spaceProductType').removeAttr('lay-verify');
                            $('#skuCode').removeAttr('lay-verify');

                        } else if (data.spaceNature == "specialClass") { // 专类存储
                            $('#spaceProductTypeBox').show();
                            $('#principal').removeAttr('lay-verify');
                            $('#skuCode').removeAttr('lay-verify');
                        } else if(data.spaceNature == "sku"){
                            $('#skuCodeBox').show();
                            $('#spaceProductType').removeAttr('lay-verify');
                            $('#principal').removeAttr('lay-verify');

                        } else{
                            // 公共存储   报修存储   回收报废存储
                            $('#spaceProductTypeBox').hide();
                            $('#spaceProductType').val('');
                            $('#spaceProductType').removeAttr('lay-verify');
                            $('#principalBox').hide();
                            $('#principal').val('');
                            $('#principal').removeAttr('lay-verify');

                            $('#skuCodeBox').hide();
                            $('#skuCodeBox').val('');
                            $('#skuCodeBox').removeAttr('lay-verify');
                        }
                    }*/


                                form.val("supplyParametersModifyForm", data);
                                form.render();


                                // /cabinet/admin/cabinetCargoLane/update
                                /**
                                 form.on('select(supplyParametersModifySpaceNature)', d => {
                        //spaceProductTypeBox存储类目  principalBox 权责人

                        if (d.value == "personal") { //专人存储
                            $('#principalBox').show();
                            $('#principal').attr('lay-verify', "required");

                            $('#spaceProductTypeBox').hide();
                            $('#spaceProductType').val('');
                            $('#spaceProductType').removeAttr('lay-verify');

                            $('#skuCodeBox').hide();
                            $('#skuCode').val('');
                            $('#skuCode').removeAttr('lay-verify');


                        } else if (d.value == "specialClass") { // 专类存储
                            $('#spaceProductTypeBox').show();
                            $('#spaceProductType').attr('lay-verify', "required");

                            $('#principalBox').hide();
                            $('#principal').val('');
                            $('#principal').removeAttr('lay-verify');

                            $('#skuCodeBox').hide();
                            $('#skuCode').val('');
                            $('#skuCode').removeAttr('lay-verify');

                        }else if(d.value=='sku'){

                            $('#skuCodeBox').show();
                            $('#skuCode').attr('lay-verify', "required");

                            $('#spaceProductTypeBox').hide();
                            $('#spaceProductType').val('');
                            $('#spaceProductType').removeAttr('lay-verify');

                            $('#principalBox').hide();
                            $('#principal').val('');
                            $('#principal').removeAttr('lay-verify');

                        }else {
                            // 公共存储   报修存储   回收报废存储
                            $('#spaceProductTypeBox').hide();
                            $('#spaceProductType').val('');
                            $('#spaceProductType').removeAttr('lay-verify');
                            $('#principalBox').hide();
                            $('#principal').val('');
                            $('#principal').removeAttr('lay-verify');

                            $('#skuCodeBox').hide();
                            $('#skuCode').val('');
                            $('#skuCode').removeAttr('lay-verify');

                        }
                    })*/

                                form.on('submit(supplyParametersModifyFormbtn)', function (d) {
                                    /* if(d.field.principal!=''){
                                         d.field.principalName=$("#principal option:selected").text();
                                     }else{
                                         d.field.principalName='';
                                     }*/
                                    let allNewData = Object.assign(data, d.field);
                                    admin.req('enterprisecab/cabinet/admin/cabinetCargoSpace/update', allNewData, function (res) {
                                        layer.closeAll('loading');
                                        if (res.code == 200) {
                                            layer.msg(res.msg, {icon: 1});
                                            layer.close(supplyParametersModifyFormPopup);
                                            getMainCabinetStagingData();
                                        } else {
                                            layer.msg(res.msg, {icon: 2});
                                        }
                                    }, 'PUT', 'true');
                                })
                            }
                        });
                    }
                }
            });
        }

        /*主柜暂存柜明细弹窗*/
        function showMainCabinetStagingDetailed(data) {
            admin.open({
                type: 1,
                area: ['1480px', '710px'],
                offset: '75px',
                title: '库存明细',
                content: $('#mainCabinetStagingDetailedForm').html(),
                success: function () {
                    let cabType = data.cabinetNature;
                    let queryFlag = undefined;
                    let url = config.base + 'enterprisecab/cabinet/admin/cabinetCargoSpace/list?cabinetId=' + data.cabinetId + '&sort=id' + '&spaceCode4Query=' + data.spaceCode;
                    if (cabType == 'main') {
                        queryFlag = 'mainCab';
                        url = config.base + 'enterprisecab/cabinet/admin/cabinetCargoSpace/list4MainCab?mainCabCode=' + data.cabCode + '&sort=id' + '&queryFlag=' + queryFlag + '&cabinetNature=live' + '&spaceCode=' + data.spaceCode;
                    }

                    let mainCabinetStagingDetailedTb = table.render({
                        elem: '#mainCabinetStagingDetailedTable',
                        url: url,
                        page: true,
                        cellMinWidth: 100,
                        id: 'commonToolCabinetTable',
                        cols: [[
                            {field: 'spaceCode', title: '货位'}
                            , {field: 'cabCode', title: '所属柜子'}
                            , {field: 'productTypeName', title: '已存物料类型'}
                            , {field: 'skuCode', title: '已存物料编号'}
                            , {field: 'brandName', title: '品牌'}
                            , {field: 'quantityInventory', title: '库存数量'}
                            , {field: 'quantity', title: '库存容量'}
                            , {field: 'businessStatusDesc', title: '货道状态'}
                            , {field: 'spaceTypeDesc', title: '货道性质'}
                            , {field: 'spaceProductTypeName', title: '物料类型'}
                            , {field: 'skuCodeTarget', title: '物料编号'}
                            , {field: 'principalName', title: '专人'}
                            , {field: 'businessTypeDesc', title: '业务状态'}
                        ]],
                        done: function (d) {
                        }
                    });
                }
            })
        }


        /*主柜物料点击事件*/
        $('#mainBoxList').delegate('.product', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            productPop(data);
        });

        /*副柜物料点击事件*/
        $('#auxiliaryBoxList').delegate('.product', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            productPop(data);
        });

        /*物料弹窗*/
        function productPop(data) {
            admin.open({
                type: 1,
                area: ['1200px', '750px'],
                offset: '65px',
                title: '物料',
                content: $('#mainCabinetProductForm').html(),
                success: function () {
                    let cabNature = data.cabinetNature;
                    let cabType = data.cabinetType;
                    let queryFlag = undefined;
                    let url = '';
                    if (cabType == 'spring') {
                        if (cabNature == 'main') {
                            queryFlag = 'mainCab';
                            url = config.base + 'enterprisecab/cabinet/admin/cellSingleInventoryProduct/list4MainCab?mainCabCode=' + data.cabCode + '&queryFlag=' + queryFlag + '&cabinetNature=sale';
                        }else if(cabNature == 'sale'){  //"售刀副柜"
                            url = config.base + 'enterprisecab/cabinet/admin/cellSingleInventoryProduct/list4ChildCab?cabCode=' + data.code;
                        }else if(cabNature == 'live'){ // "存刀副柜"
                            url = config.base + 'enterprisecab/cabinet/admin/storageSingleInventoryProduct/list?cabCode=' + data.code;
                        }
                    } else {
                        url = config.base + 'enterprisecab/wcabinet/admin/wcabCellSingleInventoryProduct/list4ChildCab?cabCode=' + data.code;
                        if (cabNature == 'main') {
                            queryFlag = 'mainCab';
                            url = config.base + 'enterprisecab/wcabinet/admin/wcabCellSingleInventoryProduct/list4MainCab?mainCabCode=' + data.cabCode + '&queryFlag=' + queryFlag + '&cabinetNature=sale';
                        }
                    }

                    $('#mainCabinetProductFormExport').click(function () {
                        let obj = getUrlQueryParams(url), str = '?';
                        for (let prop in obj) {
                            str += prop + "=" + obj[prop] + "&";
                        }
                        if (data.cabinetNature == 'main') {
                            location.href = config.base + 'enterprisecab/cabinet/admin/cellSingleInventoryProduct/export' + str;
                        } else {
                            location.href = config.base + 'enterprisecab/cabinet/admin/cellSingleInventoryProduct/exportChild' + str;
                        }
                    });

                    function getUrlQueryParams(url) {
                        const params = {};
                        const keys = url.match(/([^?&]+)(?==)/g);
                        const values = url.match(/(?<==)([^&]*)/g);
                        for (const index in keys) {
                            params[keys[index]] = values[index];
                        }
                        return params;
                    }

                    let mainCabinetProductCols = {
                        main:[
                            {type: 'numbers', title: '序号'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: d => "<img  style='max-height: 80px;' src='" + (d.skuPic ? d.skuPic : 'assets/images/default-icon.png') + "'/>"
                                ,width: 110
                            }
                            , {field: 'skuName', title: '物料名称'}
                            , {field: 'skuCode', title: '物料编号'}
                            , {field: 'skuSpecOld', title: '规格码'}
                            , {field: 'productBrandName', title: '品牌',width: 100}
                            , {field: 'quantity', title: '当前库存',width: 90}
                            , {field: 'alarmStock', title: '告警库存' ,width: 90}
                            , {field: 'planReplenishment', title: '最低补货目标', width: 120}
                            , {toolbar: '#productTableBar', title: '操作', width: 115}
                        ],
                        sale:[{type: 'numbers', title: '序号'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: d => "<img  style='max-height: 80px;' src='" + (d.skuPic ? d.skuPic : 'assets/images/default-icon.png') + "'/>"
                                ,width: 110
                            }
                            , {field: 'skuName', title: '物料名称'}
                            , {field: 'skuCode', title: '物料编号'}
                            , {field: 'skuSpecOld', title: '规格码'}
                            , {field: 'productBrandName', title: '品牌',width: 100}
                            , {field: 'quantity', title: '当前库存',width: 100}
                            , {toolbar: '#productTableBar', title: '操作', width: 115}],
                        live:[
                            {type: 'numbers', title: '序号'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: d => "<img  style='max-height: 80px;' src='" + (d.skuPic ? d.skuPic : 'assets/images/default-icon.png') + "'/>"
                                ,width: 110
                            }
                            , {field: 'skuName', title: '物料名称'}
                            , {field: 'skuCode', title: '物料编号'}
                            , {field: 'skuSpecOld', title: '规格码'}
                            , {field: 'productBrandName', title: '品牌',width: 100}
                            , {field: 'quantity', title: '当前库存',width: 100}
                            , {toolbar: '#productTableBar', title: '操作', width: 115}
                        ]
                    };
                    let mainCabinetProductTb = table.render({
                        elem: '#mainCabinetProductTable',
                        url: url,
                        page: true,
                        cellMinWidth: 100,
                        limit: 5,
                        limits: [5, 10, 20, 30, 40, 50, 60, 70, 80],
                        id: 'mainCabinetProductTable',
                        cols: [mainCabinetProductCols[data.cabinetNature]?mainCabinetProductCols[data.cabinetNature]:mainCabinetProductCols['main']],
                        parseData: function (res) {
                            if (res.data.length === 0) {
                                $('#mainCabinetProductFormExport').hide()
                            } else {
                                $('#mainCabinetProductFormExport').show()
                            }
                            res.data.forEach(item => {
                                item.cabinetNature = data.cabinetNature;
                                if (cabNature == 'main') {
                                    item.cabCode = data.cabCode;
                                }
                            });
                            return res;
                        },
                        done: function (d) {
                        }
                    });

                    // 工具条点击事件
                    table.on('tool(mainCabinetProductTable)', function (obj) {
                        let dataProduct = obj.data;
                        if (obj.event === 'distributionCargoWayBtn') { //分布货道
                            var cabType = data.cabinetNature;
                            var queryFlag = undefined;
                            if (cabType == 'main') {
                                queryFlag = 'mainCab';
                                dataProduct.mainCabCode = data.cabCode;
                            }
                            dataProduct.queryFlag = queryFlag;
                            dataProduct.cabinetNature = data.cabinetNature;
                            dataProduct.cabinetType = data.cabinetType;
                            showDistributionCargoWay(dataProduct)
                        } else if (obj.event === 'alarmSettingBtn') {  // 告警设置
                            showAlarmSetting(dataProduct);
                        } else if (obj.event === 'loadingShelvesBtn') { // 上货
                        }
                    });

                    form.on('submit(mainCabinetProductSearch)', function (data) {
                        mainCabinetProductTb.reload({where: data.field, page: {curr: 1}}, 'data');
                    });

                    // 显示告警设置
                    function showAlarmSetting(data) {
                        var alarmSettingPopup = admin.open({
                            type: 1,
                            area: '700px',
                            offset: '100px',
                            title: '告警设置',
                            content: $('#alarmSetting').html(),
                            success: function (_data) {
                                if (data.thresholdBlack === 0) {
                                    data.thresholdBlack = ""
                                }

                                form.val('alarmSettingForm', data);
                            }
                        });
                        form.render();
                        form.on('submit(alarmSettingSubBtn)', function (d) {
                            let newObj = {};
                            d.field.cabCode = data.cabCode;
                            Object.assign(newObj, data, d.field);
                            admin.req('enterprisecab/cabinet/admin/cabAlarmSettings/add', newObj, function (res) {
                                layer.closeAll('loading');
                                if (res.code == 200) {
                                    layer.msg(res.msg, {icon: 1});
                                    table.reload('mainCabinetProductTable');
                                    layer.close(alarmSettingPopup)
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }, 'POST', 'true');


                        })
                    }

                    // 显示分布货道
                    function showDistributionCargoWay(data) {
                        admin.open({
                            type: 1,
                            area: ['1000px', '600px'],
                            offset: '100px',
                            title: '分布货道',
                            content: $('#distributionCargoWay').html(),
                            success: function () {
                                var cabNature = data.cabinetNature;
                                var cabType = data.cabinetType;
                                var url = '';
                                if (cabType == 'spring') {
                                    url = config.base + 'enterprisecab/cabinet/admin/cellInventorySpace/list?cabCode=' + data.cabCode + '&skuCode4Detail=' + data.skuCode;
                                    if (cabNature == 'main') {
                                        url = config.base + 'enterprisecab/cabinet/admin/cellInventorySpace/list?mainCabCode=' + data.mainCabCode + '&skuCode4Detail=' + data.skuCode + '&queryFlag=mainCab&cabinetNature=sale';
                                    }
                                } else {
                                    url = config.base + 'enterprisecab/wcabinet/admin/wcabCellInventorySpace/list?cabCode=' + data.cabCode + '&skuCode4Detail=' + data.skuCode;
                                    if (cabNature == 'main') {
                                        url = config.base + 'enterprisecab/wcabinet/admin/wcabCellInventorySpace/list?mainCabCode=' + data.mainCabCode + '&skuCode4Detail=' + data.skuCode + '&queryFlag=mainCab&cabinetNature=sale';
                                    }
                                }

                                form.render();
                                var productTb = table.render({
                                    elem: '#distributionCargoWayTable',
                                    // url: config.base + 'enterprisecab/cabinet/app/cellSingleInventoryProduct/list?cabCode=' + data.cabCode,
                                    url: url,
                                    page: true,
                                    cellMinWidth: 100,
                                    height: 510,
                                    cols: [[
                                        {type: 'numbers', title: '序号'}
                                        , {field: 'spaceCode', title: '货道', sort: true}
                                        , {field: 'cabCode', title: '柜子编号'}
                                        , {field: 'skuName', title: '物料名称'}
                                        , {field: 'skuCode', title: '物料编号'}
                                        , {field: 'productBrandName', title: '品牌'}
                                        , {field: 'quantity', title: '数量'}
                                        , {field: 'packName', title: '包装规格'}
                                        , {
                                            field: 'quantity', title: '基础单位数量', templet: function (d) {
                                                return d.quantityPack + d.unitName;
                                            }
                                        }
                                        // , {field: '', title: '备注'}
                                        // , {field: 'status', title: '货道状态'}
                                        // , {field: '', title: '截至时间'}
                                    ]],
                                })
                            }
                        })
                    }

                }
            });
        }

        /*主柜订单点击事件*/
        $('#mainBoxList').delegate('.order', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            orderPop(data)
        });


        /*副柜订单点击事件*/
        $('#auxiliaryBoxList').delegate('.order', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            orderPop(data)
        });

        /*订单弹窗*/
        function orderPop(data) {
            admin.open({
                type: 1,
                area: ['1200px', '800px'],
                offset: '65px',
                title: '订单列表',
                content: $('#mainCabinetOrderForm').html(),
                success: function () {
                    let cabNature = data.cabinetNature, cabType = data.cabinetType, queryFlag = undefined, url = '';
                    let limit = 4, page = 1;
                    if (cabType == 'spring') {
                        url = 'enterprisecab/cabinet/admin/cellInventoryOut/list?cabCode=' + data.code;
                        if (cabNature == 'main') {
                            queryFlag = 'mainCab';
                            url = 'enterprisecab/cabinet/admin/cellInventoryOut/list?mainCabCode=' + data.cabCode + '&queryFlag=' + queryFlag + '&cabinetNature=sale';
                        }
                    } else {
                        url = 'enterprisecab/wcabinet/admin/wcabCellInventoryOut/list?cabCode=' + data.code;
                        if (cabNature == 'main') {
                            queryFlag = 'mainCab';
                            url = 'enterprisecab/wcabinet/admin/wcabCellInventoryOut/list?mainCabCode=' + data.cabCode + '&queryFlag=' + queryFlag + '&cabinetNature=sale';
                        }
                    }

                    //搜索
                    form.on('submit(mainCabinetOrderSearch)', function (data) {
                        page = 1;
                        getMainCabinetOrderData(data.field);
                        return false;
                    });
                    getMainCabinetOrderData();

                    //请求订单数据
                    function getMainCabinetOrderData(_data) {
                        let obj = Object.assign({}, {limit, page}, _data);
                        layer.load(2);
                        admin.req(url, obj, res => {
                            layer.closeAll('loading');
                            if (res.code === 200) {
                                showMainCabinetOrderHtml(res.data);
                                laypage.render({
                                    elem: 'mainCabinetOrderPage', count: res.count, limit, curr: page
                                    , jump: function (obj, first) {
                                        if (!first) {
                                            page = obj.curr;
                                            getMainCabinetOrderData();
                                        }
                                    }
                                });
                            } else {
                                showMainCabinetOrderHtml([])
                            }
                        })
                    }

                    //渲染订单页面
                    function showMainCabinetOrderHtml(_data) {
                        if (!_data || _data.length === 0) {
                            $('#mainCabinetOrderBox').html('<h3 class="noData">暂无内容~~~</h3>');
                            return false;
                        }
                        let html = '';
                        _data.forEach(item => {
                            html += `<div class="mainCabinetOrderItem" data='${JSON.stringify(item)}' >
                                        <div class="mainCabinetOrderItemHeader">
                                            <div class="mainCabinetOrderItemCode">订单编号：${item.code}</div>
                                            <div class="mainCabinetOrderItemNum">${item.spaceCode}</div>
                                        </div>
                                        <div class="mainCabinetOrderItemCenter">
                                            <div class="mainCabinetOrderItemImg">
                                                <div><img src="${item.skuPic || 'assets/images/default-icon.png'}"></div>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>物料名称</p>
                                                <p>${item.skuName}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>物料编号</p>
                                                <p>${item.skuCode}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>品牌</p>
                                                <p>${item.productBrandName}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>领取数量</p>
                                                <p>${Math.abs(item.quantity)}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>柜子数量</p>
                                                <p>${item.cabCode}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemInfo">
                                                <p>领取人</p>
                                                <p>${item.creatorName}</p>
                                            </div>
                                            <div class="mainCabinetOrderItemBtn">
                                                <a class="layui-btn layui-btn-primary layui-btn-xs mainCabinetOrderItemBtnDetails">详情</a>
                                            </div>
                                        </div>
                                    </div>`;
                        });
                        $('#mainCabinetOrderBox').html(html);
                    }


                    $('#mainCabinetOrderBox').delegate('.mainCabinetOrderItemBtnDetails', 'click', function (e) {
                        showMainCabinetOrderDetailsForm(JSON.parse($(this).parents('.mainCabinetOrderItem').attr('data')));
                    });

                }
            });
        }

        /*主柜订单详情弹窗*/
        function showMainCabinetOrderDetailsForm(_data) {
            admin.open({
                type: 1,
                area: ['1000px', '500px'],
                offset: '85px',
                title: '订单列表详情',
                content: $('#mainCabinetOrderDetailsForm').html(),
                success: function () {
                    _data.quantity = Math.abs(_data.quantity);
                    $('#mainCabinetOrderDetailsSkuPic').html('<img src="' + _data.skuPic + '" style="width: 100%;height: 100%">');
                    form.val('mainCabinetOrderDetailsForm', _data);
                }
            });
        }

        /*主柜修改点击事件*/
        $('#mainBoxList').delegate('.modify', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.mainBoxItem').attr('data'));
            modifyPop(data)
        });

        /*副柜修改点击事件*/
        $('#auxiliaryBoxList').delegate('.modify', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            modifyPop(data)
        });

        /*修改弹窗*/
        function modifyPop(data) {
            admin.open({
                type: 1,
                area: ['450px', '500px'],
                offset: '65px',
                title: '修改',
                content: $('#mainCabinetModifyForm').html(),
                success: function () {

                    if (data.cabinetNature != "main") {
                        $('form[lay-filter="mainCabinetModifyForm"]').find('select[name="settledCompanyId"]').attr('disabled', 'disabled');
                        $('form[lay-filter="mainCabinetModifyForm"]').find('input[name="workshopLocation"]').attr('disabled', 'disabled');
                        $('form[lay-filter="mainCabinetModifyForm"]').find('select[name="workshopId"]').attr('disabled', 'disabled');

                    }

                    // 获取企业数据
                    admin.reqSync('user/admin/companyInfo/list', {limit: 9999}, function (res) {
                        if (res.code == 200) {
                            loadSelectHtmlNew(res.data, '请选择企业', 'settledCompanyId', '[lay-filter="mainCabinetModifyForm"]', 1);
                        } else {
                            loadSelectHtmlNew([], '请选择企业', 'settledCompanyId', '[lay-filter="mainCabinetModifyForm"]', 1);
                        }
                    }, 'GET');

                    // 获取所属车间
                    admin.reqSync('enterprise/system/admin/roomInfo/findWorkshop', {limit: 9999}, function (res) {
                        if (res.code == 200) {
                            loadSelectHtmlNew(res.data, '所属车间', 'workshopId', '[lay-filter="mainCabinetModifyForm"]', 5);
                        } else {
                            loadSelectHtmlNew([], '所属车间', 'workshopId', '[lay-filter="mainCabinetModifyForm"]', 5);
                        }
                    }, 'GET');

                    form.val('mainCabinetModifyForm', data);

                    // 表单提交事件
                    form.on('submit(mainCabinetModifyFormSubmit)', function (d) {
                        layer.load(2);
                        d.field.cabCode = data.cabCode;
                        d.field.settledCompanyName = $("form select[name='settledCompanyId'] option:selected").text();
                        admin.req('enterprisecab/cabinet/admin/cabinet/updateCompany', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                layer.closeAll('page');
                                init();
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'PUT');
                        return false;
                    });

                }
            });
        }

        /*副柜转移*/
        $('#auxiliaryBoxList').delegate('.transfer', 'click', function (e) {
            e.stopPropagation(); /*阻止冒泡*/
            let data = JSON.parse($(this).parents('.auxiliaryBoxItem').attr('data'));
            admin.open({
                type: 1,
                area: ['430px', '390px'],
                offset: '65px',
                title: '转移',
                content: $('#transferForm').html(),
                success: function () {
                    $('form[lay-filter="transferForm"] input[name="id"]').val(data.id);
                    $('#transferFrom').val(data.belongCabinet);
                    form.render('select');
                    admin.req('enterprisecab/cabinet/admin/cabinet/list', {
                        cabinetNature: 'main',
                        cabinetTypeId: "",
                        cabinetBrandId: "",
                        status: "",
                        code: "",
                        cabinetType: "spring"
                    }, res => {
                        if (res.code === 200) {
                            loadSelectHtmlNew(res.data, '请选择主柜', 'belongCabinet', '[lay-filter="transferForm"]', 4);
                        } else {
                            loadSelectHtmlNew([], '请选择主柜', 'belongCabinet', '[lay-filter="transferForm"]', 4);
                        }
                    });

                    form.on('submit(transferFormSubmit)', function (d) {
                        layer.load(2);
                        admin.req('enterprisecab/cabinet/admin/cabinet/update', d.field, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                layer.closeAll('page');
                                init();
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'PUT');
                        return false;
                    });

                }
            });
        });

        /*渲染下拉框*/
        function loadSelectHtmlNew(data, tips, htmltarget, formName, type) {
            let html = '';
            if(tips){
                html = '<option value>' + tips + '</option>'
            }
            if (!data || data == null) {
                $("form" + formName + " select[name='" + htmltarget + "']").html(html);
                form.render('select');
                return;
            }

            for (let i = 0; i < data.length; i++) {
                if (type == 1) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                } else if (type == 2) {
                    html += `<option value='${data[i].id}'>${data[i].nickname}</option>`;
                } else if (type == 3) {
                    html += `<option value='${data[i].value}'>${data[i].name}</option>`;
                } else if (type == 4) {
                    html += `<option value='${data[i].cabCode}'>${data[i].cabCode}</option>`;
                } else if (type == 5) {
                    html += `<option value='${data[i].id}'>${data[i].roomName}</option>`;
                } else if (type == 6) {
                    html += `<option value='${data[i].code}'>${data[i].code}</option>`;
                }else if(type == 7){
                    html += `<option value='${data[i].id}' data='${JSON.stringify(data[i])}'>${data[i].nickname}</option>`;
                }

            }
            $(formName + " select[name='" + htmltarget + "']").html(html);
            form.render('select');
        }
    });
</script>